Sam*_*Sam 5 typescript react-native
我TypeScript在我的react-native项目中使用,它工作正常。我遇到的唯一问题是,IDE 向我显示了错误和所有内容。但即使有一些打字稿错误,我仍然能够运行我的项目。例如,如果我有一个打字稿错误
type something = 'abc'
Run Code Online (Sandbox Code Playgroud)
const fn(arg: something){ }
fn('somethingelse')
Run Code Online (Sandbox Code Playgroud)
IDE 将显示somethingelse未分配给abc. 但是当我重新加载应用程序/捆绑包时。它仍然编译。我添加了一些我的打字稿配置文件
tsconfig.json
{
"compilerOptions": {
"baseUrl": "app",
"target": "es2018",
"lib": ["dom", "dom.iterable", "esnext"],
"jsx": "preserve",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"declaration": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": false,
"isolatedModules": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noLib": false,
"noUnusedParameters": true,
"noUnusedLocals": true,
"pretty": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"removeComments": true,
"sourceMap": true,
"strict": true,
"suppressImplicitAnyIndexErrors": true,
"module": "esnext",
"moduleResolution": "node",
"noEmit": true
},
"typeAcquisition": {
"include": ["jest"]
},
"include": ["app/**/*", "test-utils"]
}
Run Code Online (Sandbox Code Playgroud)
当我也这样做时,yarn tsc我收到此错误
TypeError: Cannot read property 'kind' of undefined
虽然 tsc --w 有效,但我希望在运行时出现这些错误,以便我可以在它们发生时修复它们。现在我只在 IDE 上看到这些错误。但它仍然编译。
| 归档时间: |
|
| 查看次数: |
293 次 |
| 最近记录: |