The typescript docs state that in tsconfig.json
we can control input files either with files
where we list all files, or with exclude
. I have all my source files in a src
directory and only want to compile all files that are there (to a bifferent directory, build
). I could exclude
all other files and directories, but I might miss something. I don't want to manually add every file to files
.
How can I specify to typescript that it should compile only the typescript files it finds in the src
directory, and nothing else?
Typescript file does not run directly on the browser as javascript run, we have to compile the typescript file to the javascript then it will work as usual. In order to compile & run any typescript file, first, we need to install node and using it install typescript globally in your local system.
Tsc stands for `TypeScript compiler` and is a simple tool included in Typescript itself, allowing you to compile any ts files into js.
TypeScript provides a command-line utility tsc that compiles (transpiles) TypeScript files ( . ts ) into JavaScript. However, the tsc compiler (short for TypeScript compiler) needs a JSON configuration file to look for TypeScript files in the project and generate valid output files at a correct location.
Hence, the TypeScript code needs to get compiled into JavaScript, and for that, you need the TypeScript compiler. You can install TypeScript globally using the following npm command. The global installation allows you to run the tsc command anywhere from your terminal.
For anybody who stumbles across this question like I did -
Just like exclude
, directories can be included as well now.
I include just my src directory like this to compile only my src:
"include": [
"./src/**/*"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With