We have an AMD Typescript project, its directory structure is similar to this:
project_root/ /scripts /ts module.ts /js (generated from the TS files) /tests /ts moduleTest.ts (imports module.ts) /js (generated from the TS files)
The problem is when we compile a file that imports another module (file) from a directory that is not a descendant of the importer's directory, the TS compiler reconstructs the entire tree from the direct common parent of the two directories, js .
So, for example, compiling tests/ts/moduleTest.ts (which imports scripts/ts/module.ts ) into the tests/js directory will give this directory tests/js :
project_root/tests/js /scripts/ts module1.js /tests/ts module1test.js
instead of just module1test.js in project_root/tests/js . In real life, this will be even worse, since module1.ts itself will import more modules from subdirectories, all of which will be created in project_root/tests/js .
In addition to importing created .js files and links to .d.ts files, not importing .ts files. Is there a solution to create an entire tree? Preferably, is there a way to tell the compiler not to compile the imported TS files, but to use them only as a reference?
I made a basic example / test repository to use as a playground. To find out what I'm talking about, from the root of the project, run:
tsc --module amd -t ES5 --outDir tests/js/ tests/ts/module1spec.ts
This project uses requireAdapters.d.ts to avoid using relative module names in the import statement (in other words, it translates TS names and require.js).
Lior source share