js项目迁移到ts上,eslint检查报错:
@typescript-eslint/no-use-before-define: 'React' was used before it was defined.
查阅资料,在eslintrc.js
中新增配置如下:
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
但是依然未解决问题,最终的解决方案为:
The bug occurs due to mismatch of @typescript-eslint versions in react-scripts and your local package.json - GitHub issue
"@typescript-eslint/eslint-plugin": "4.0.1",
"@typescript-eslint/parser": "4.0.1",
对安装包做降级处理后,问题得到解决。