我有一个Nativescript代码共享项目。扩展名为tns.ts的文件中的模块无法通过打字稿解析。我收到以下消息。我认为发生这种情况是因为tsconfig.json中排除了所有tns.ts,android.ts和ios.ts文件。
这是来自https://github.com/NativeScript/web-mobile-project项目。我添加了第5行以显示错误。在第13行中也有一个错误。它说应该启用实验装饰器。在两个配置文件中都启用了该功能,但由于忽略tsconfig.tns.json和tsconfig.json文件,我仍然收到此错误。
仅在文件扩展名为tns.ts时才会发生。找到没有扩展名tns.ts的文件中的所有模块,并且 Atom编辑器未显示错误。
我该如何解决这个问题?
这是我的tsconfig.json文件:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"es6",
"es2015.iterable"
],
"baseUrl": "./",
"paths": {
"~/*": [
"src/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
],
"@shared/*": [
"src/app/shared/*"
],
"@models/*": [
"src/app/shared/models/*"
],
"@core/*": [
"src/app/core/*"
],
"@components/*": [
"src/app/components/*"
]
}
},
"exclude": [
"**/*.tns.ts",
"**/*.android.ts",
"**/*.ios.ts",
"**/*.spec.ts"
]
}
这是tsconfig.tns.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node",
"baseUrl": "./",
"experimentalDecorators": true,
"paths": {
"~/*": [
"src/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
],
"@shared/*": [
"src/app/shared/*"
],
"@models/*": [
"src/app/shared/models/*"
],
"@core/*": [
"src/app/core/*"
],
"@components/*": [
"src/app/components/*"
]
}
}
}