tsconfig.json for project with `src` and `tests`
typescript
Solution
You may use `rootDirs` option within `tsconfig.json` such as:
{
"compilerOptions": {
"rootDirs": [
"src",
"tests"
]
}
}
This can be looked up at Typescript documents, on this page (search for Virtual Directories with rootDirs subtitle): Module Resolution
Problem
I've got a (desired) structure like this: ``` - tsconfig.json - src - app.ts - tests - appTest.ts - appTest.js - dist - app.js ``` If there was no `tests` folder, a tsconfig.json like this would work fine: ``` { "compilerOptions": { "outDir":"dist" }, "include" :[ "src/**/*.ts" ] } ``` However, if I add `tests/**/*.ts` to the `include` element, it also compiles my test files into `dist` and changes its folder structure (understandably, but undesirably). Can I tell TypeScript compiler to include test files in the project to support things like refactoring but omit them from output to `dist`? Specifically, I'd like the `.js` to be compiled in the `tests` directory as suggested in the structure above.