This question is a little older, I know. But some of the TypeScript compiler options listed here do not necessarily help resolve this issue. For people looking for rootDir or similar (like me), it may be helpful to clarify the options mentioned and related to the solution.
Extract all files into one file
✅ Use outFile
❌ Do not use out (deprecated)
Reference Information:
If you want to create a destination directory, select outDir . See compiler options for more information.
List files only from a specific directory
✅ Use files / include / exclude in tsconfig
❌ Do not use rootDir
Explanation:
The compiler finds all input files by
- view
file / include / exclude properties - following
import statements - after
///<reference .. /> (should no longer matter)
If these parameters are not specified, all files in the root of the TypeScript project (provided by tsconfig.json) will be included. Import import automatically enabled by the compiler, regardless of file / include / exclude - take a look at their FAQ . All input files together are an envelope of files that it will create. How to configure file / include / exclude , see Tsconfig.json docs , also see @TSV answer.
Roottir
rootDir manages the structure of the output directory with outDir , it is not used to specify the input to the compiler. Its use ( quote ):
For each input file (i.e. .ts / .tsx file), you must create the corresponding output file (.js / .jsx file). To find out the path to the file of the generated output file, it will cut "rootDir" from the input and then add "outDir" to it.
Therefore, rootDir needs a directory that includes all of your input sources at the top, otherwise you will get
error TS6059: file is not located in the "rootDir" section. "RootDir" is expected to contain all source files
If rootDir omitted, the compiler automatically calculates the appropriate directory, taking into account all the input files at hand. So it does not have to be installed.
sourceRoot
This option is only relevant for source maps / debugging and may be omitted for the scope of the question. It is used when your source files are in a different place at runtime than during development. The compiler adjusts the source paths in the source map file to match the paths at runtime ( compiler options ).
Hope this clarifies things a bit.