rootDirs, rootDir and baseUrl in tsconfig

rootDirs & rootDir are two totally different thing, despite the names are similar.

Here is the example structure

1
2
3
4
5
root
└── compiled
└── dist
└── src
└── node_modules

rootDir is for the location of the source code, which is src.

rootDirs is for Virtual Directories.

Sometime a project might generate code for certain usage. Like in Angular AoT build, it will generate compiled code that is set by genDir

if we set genDir = "compiled", we should add compiled to rootDirs so we can reference it as it is inside src.

baseUrl is for non-relative modules import.

so it should be set as node_modules