Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript: How to compile only the files in a folder

Tags:

typescript

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?

like image 679
Ludwik Avatar asked Aug 06 '16 08:08

Ludwik


People also ask

How do I compile all files in TypeScript?

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.

What does TSC do in TypeScript?

Tsc stands for `TypeScript compiler` and is a simple tool included in Typescript itself, allowing you to compile any ts files into js.

How does TypeScript get compiled?

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.

Does TypeScript need to be compiled?

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.


1 Answers

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/**/*"
]
like image 200
Supriya Avatar answered Sep 20 '22 15:09

Supriya