Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass multiple source files to the TypeScript compiler?

Tags:

typescript

tsc

TypeScript is designed for large-scale JavaScripty projects which typically consist of multiple internally produced files along with externally produced libraries. How does the TypeScript compiler (tsc) expect you to provide it with the complete set of files that make up a project?

like image 389
CCoder Avatar asked Oct 02 '12 23:10

CCoder


People also ask

How do I compile all files in TypeScript?

Open a terminal and run tsc -w , it'll compile any . ts file in src directory into . js and store them in ts-built directory.

How does the TypeScript compiler know how do you find your source files?

When you run tsc command in a directory, TypeScript compiler looks for the tsconfig. json file in the current directory and if it doesn't find one, then it keeps looking up the directory tree until it finds one. The directory where the tsconfig. json is located is considered as the root of the project.

What command is used to compile a TypeScript file?

Here, you will learn how to compile a TypeScript project and also learn about tsconfig. json. As you know, TypeScript files can be compiled using the tsc <file name>. ts command.

Which programs can be used to automatically compile TypeScript?

You can find the complete code for tsconfig. json below. Another way of automating the TypeScript compilation is by using command line interface or the Command Prompt. The second way is pretty simple to achieve; we just need to write a single line to watch any changes in our TypeScript file.


1 Answers

dir *.ts /b /s > ts-files.txt tsc @ts-files.txt del ts-files.txt 

This will compile all *.ts files in working directory and its sub directories. If you don't want to include sub directories, just remove the /s part from the first line.

Note that you can also add other arguments to the tsc line. Here is what I'm using now for one of my projects:

tsc @ts-files.txt --out ..\output\deerchao.web.js --removeComments 
like image 139
deerchao Avatar answered Oct 03 '22 06:10

deerchao