I have a Nativescript code sharing project. Modules in files with tns.ts extension cannot be resolved by typescript. I get the following message. I think this happens because all tns.ts, android.ts and ios.ts files are excluded in tsconfig.json.
This is from https://github.com/NativeScript/web-mobile-project project. I added line 5 to show the error. Also there is an error in line 13. It says that experimentaldecorators should be enabled. It is enabled in both config files but I still get this error because tsconfig.tns.json and tsconfig.json files are ignored.
This only happens if file extension is tns.ts. All modules in files without tns.ts extension are found and Atom editor does not show an error.
How can I solve this problem?
This is my tsconfig.json file:
{
"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"
]
}
This is 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/*"
]
}
}
}