reactnativecn / react-native-website

React Native 中文网
https://reactnative.cn
MIT License
216 stars 327 forks source link

no-unused-vars 设置 ‘error’,无效 #623

Closed Span134 closed 1 year ago

Span134 commented 1 year ago

问题的具体描述

image

项目命令 npx react-native init AwesomeTSProject --template react-native-template-typescript 生成, 然后App.tsx添加了未使用的变量,tsconfig与eslintrc分别添加配置,启动项目

预期结果 : 希望编译失败,模拟器直接提示 'abc' is decleared but value never read ! 实际结果 : 项目编译成功

请描述完整的环境/版本信息

win10 node 16.16.0 "eslint": "^7.32.0", "typescript": "^4.4.4" "@typescript-eslint/eslint-plugin": "^5.29.0", "@typescript-eslint/parser": "^5.29.0",

sunnylqm commented 1 year ago

rn是通过babel来支持ts的,而babel是不做类型检查的 https://babeljs.io/docs/en/babel-plugin-transform-typescript#impartial-namespace-support

image

一般来说,我们在npm scripts中添加tsc命令来做额外的检查,但也只在提交代码或者pr,或者发布版本前做检查,平时依靠编辑器做检查就行了,编译前做检查纯粹是浪费时间

github-actions[bot] commented 1 year ago

👋 Hey there, it looks like there has been no activity on this issue in the last 90 days. Has the issue been fixed, or does it still require the community attention? This issue will be closed in the next 7 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.