【发布时间】:2019-06-05 17:59:50
【问题描述】:
我目前正在将我的 RN 项目迁移到 TypeScript。我已经完成了我的大部分 JS 代码,现在当我运行 tsc 时,我遇到了数百个似乎都是错误的错误
error TS 2717: Subsequent property declarations must have the same type. Property
prop must be of the type TYPE,
but here has type TYPE
例如:
error TS2717: Subsequent property declarations must have the same type. Property
'view' must be of type 'SVGProps<SVGViewElement>',
but here has type 'SVGProps<SVGViewElement>'.
这是双重混淆,因为列出的类型几乎总是相同的。
我能够运行我的应用程序,我仍然从 tslint 收到有用的消息,并且任何特定于我的代码的错误都会出现在编译器错误列表的底部。
我的tsconfig.json 目前是:
{
"compilerOptions": {
"allowJs": true,
"target": "es2018",
"outDir": "dist",
"module": "commonjs",
"sourceMap": true,
"lib": ["esnext", "es7", "dom", "es6"],
"jsx": "react-native",
"strict": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": ["react-native"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
我尝试了各种解决方案,包括根据 TypeScript 文档将types 设置为[],并将exclude 设置为各种形式的node_modules,例如./node_modules、node_modules/* 等,但这些都不是更改产生了任何影响。
【问题讨论】:
标签: typescript