Closed
Description
TypeScript Version: all
Code
importing files, for example
import 'reflect-metadata/Reflect.js';
causes the following exception in tsc:
error TS6059: File 'client/node_modules/reflect-metadata/Reflect.ts' is not under 'rootDir'
'client/src'. 'rootDir' is expected to contain all source files.
the tsconfig.json looks like this:
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"rootDir": "./src",
"sourceMap": true,
"target": "es5",
"outDir": "dist/"
},
"files": [
"src/bootstrap.ts"
]
}
Expected behavior:
Suggestions:
- don't try to recompile .ts files not under rootDir if there is a js file there (if there isn't throw the same exception)
- don't try to recompile .ts files under node_modules folder unless there is no js file there
- don't compile excluded files even if referenced (that way you can use both "files" and "excluded" in the tsconfig.
- some configuration like
compileDependencies: 'true'/['specific-dependency1', 'dep2']/false
Actual behavior:
tries to recompile everything even if it's from node_modules folder and even if I don't directly reference the .ts file and reference the .js file instead
workaround 1: reference the.d.ts file instead of the .js file (doesn't work if the module itself has dependencies)
workaround 2: put the .ts and the .d.ts+.js files in a different folder in the library but it's not possible for existing libraries since they are provided by a third party.