我已经启动了一个新的create-react-app(CRA)项目,以替换不使用CRA的现有React项目。该项目正在使用TypeScript,而我的IDE是WebStorm。
我的package.json文件在devDependencies中包含以下模块:
"@types/react": "~16.9.50",
"@typescript-eslint/eslint-plugin": "~4.3.0",
"eslint": "6.6.0",
"eslint-config-airbnb-typescript": "~11.0.0",
"eslint-plugin-import": "~2.22.1",
"eslint-plugin-jsx-a11y": "~6.3.1",
"eslint-plugin-react": "~7.21.3",
"eslint-plugin-react-hooks": "~4.1.2",
"typescript": "~4.0.3"
一个组件的示例如下:
import React, { FunctionComponent } from 'react';
const Content: FunctionComponent = () => (
<div>Hello</div>
);
export { Content };
ESLint / WebStorm抱怨以下错误:
ESLint: 'FunctionComponent' is defined but never used.(@typescript-eslint/no-unused-vars)
我的代码仍然可以编译,没有任何错误或警告,并且我的网站可以正常运行。我以前的项目在识别TypeScript类型方面没有任何问题。我安装了@types模块。我认为.eslintrc,tsconfig.json的相关部分和WebStorm中的相关设置是相同的。
有人有什么见识吗?
答案 0 :(得分:0)
我通过升级到react-scripts 4.0解决了这个问题