【发布时间】:2021-10-22 05:41:03
【问题描述】:
我有这个tsconfig.json 文件
{
"compilerOptions": {
"target": "es2019",
"lib": [
"es2020",
"esnext.asynciterable"
],
"typeRoots": [
"./node_modules/@types",
"./src/types"
],
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"module": "commonjs",
"pretty": true,
"sourceMap": true,
"outDir": "./build",
"allowJs": true,
"noEmit": false
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules",
"tests"
]
}
据您所知,那里没有严格的规定。对我来说最重要的是它开始使用strictNullChecks 设置,但是我的项目已经很大了,当我将此设置设置为true 时,我有大约1000 个错误。
我想开始重构代码以避免潜在问题,但我想一步一步地移动,一个文件一个文件,不想一次解决 1000 个错误。
我怎样才能实现它?
我计划对每个错误行使用注释// @ts-ignore,然后逐步解决问题。但是加// @ts-ignore 1000 次就更难了。我怎样才能自动完成?
请给点建议
【问题讨论】:
标签: typescript