谢谢你花时间阅读这篇文章。
我正在尝试学习使用eslint和AirBnB配置一起使用react的类型记录。像映射对象数组和使用每个对象创建自定义函数组件这样简单的事情给了我下一个错误:
Argument of type '(product: ProductType) => JSX.Element' is not assignable to parameter of type '(value: object, index: number, array: object[]) => Element'.
下面是父组件ProductGrid:
const Pr
最近,我在我的项目中升级了react/react-dom的版本,从16.3.2升级到16.8.6,以便能够使用钩子,并且在我的代码中做了一些小改动,一切都进行得很顺利。
但是我们正在使用typescript,当我尝试使用React.useState()时,typescript编译器报告说无法编译:Property 'useState' does not exist on type 'typeof React'.
我认为问题在于@types/react和@types/react-dom包不是最新的。所以我试着把它们从16.3.2升级到16.8.5 (16.8.6不
我在React和typescript中使用插槽系统。问题是我找不到一个包含slot作为属性的接口,所以我从我的typescript检查器中得到一个错误: Property 'slot' does not exist on type 'IntrinsicAttributes & IStockProps & { children?: ReactNode; }'.
我试图通过app.tsx中的组件属性向下钻取应用程序状态,但得到一个typescript错误:
Type '{ dailyObd: RouteComponentProps<any, StaticContext, {}>; }' is not assignable to type 'IntrinsicAttributes & obds & { children?: ReactNode; }'.
Property 'dailyObd' does not exist on type 'IntrinsicAttri
我正在使用create app+ typescript + eslint应用程序,在构建过程中有这样的错误:
Line 1:8: 'React' was used before it was defined @typescript-eslint/no-use-before-define
组件中的代码以以下代码开头:
import React from "react";
Eslint设置:
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
我有以下使用Typescript的import语句: import * as React from 'react';
import { MouseEvent } from 'react' Typescript抱怨我应该组合这些多个导入。我尝试了以下方法,但导入的MouseEvent是不同的: import MouseEvent, * as React from 'react' 在这个组合导入语句中,MouseEvent与通过import { MouseEvent } from 'react'导入的不同。 出于某种原因,Types
我想要构建我的NextJS应用程序,它是在类型记录中编码的。在我的本地电脑里,它工作得很好。我可以打电话给next build,它可以正常工作。在我的主机服务器中,它给出了以下错误:
> next build
It looks like you're trying to use TypeScript but do not have the required package(s) installed.
Please install typescript by running:
npm install --save-dev typescript
If you are not
我对TypeSccript非常陌生。我正在尝试将我的React Native转换为使用TypeScript。我按照这里的说明操作:https://reactnative.dev/docs/typescript 在运行yarn tsc之后,我得到如下错误: node_modules/@react-navigation/stack/lib/typescript/src/types.d.ts:99:67 - error TS2339: Property 'style' does not exist on type 'PropsWithChildren<Animated
我如何输入一个typescript变量,以便它需要一个设置了key的组件? 我想要这样的东西: const foo: ReactElementWithKey = <div key="some key"></div>
// all ok
const bar: ReactElementWithKey = <div></div>
// no `key` - typescript should show an error 我应该如何定义ReactElementWithKey? 我尝试过这样的方法: type ReactElemen