Issue
What would be an idiomatic directory structure for a TypeScript project?
I would like the following features in such a structure:
- Separate directories for TypeScript source code and transpiled JavaScript
- Separate directories for project source code and test code
- Mechanism to resolve references across tests and source code.
Solution
Looks like I was doing it wrong. I was trying the following structure:
src
|---- lib
|-----|---- mymodule.ts
|---- tests
|-----|---- mymodule.tests.ts
However, I was attempting to compile the source code under lib
directory separately from the test code under tests
.
find src/lib -name *.ts | xargs tsc --declaration --sourceMap --module commonjs --target es5 --listFiles --outDir lib
and then the tests code:
find src/tests -name *.ts | xargs tsc --declaration --sourceMap --module commonjs --target es5 --listFiles --outDir tests
This caused the tests
folder to have another lib
sub-directory and a tests
sub-directory. This was not what I intended to have.
To solve my problem I needed to compile them together, so now my command is:
find src -name *.ts | xargs tsc --declaration --sourceMap --module commonjs --target es5 --listFiles --outDir .
Thanks everybody for the help.
Answered By - codematix
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.