Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

typescript - can tsc be run against an entire folder?

Tags:

typescript

I'm pretty surprised this isn't in the docs that I could find - but is there any way to just tell tsc to run against all files in a directory and its children without going through a whole tsconfig.json setup?

like image 704
Ciel Avatar asked Mar 01 '16 21:03

Ciel


People also ask

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 do I compile all ts files in a folder?

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

Does TSC use Tsconfig?

Running tsc locally will compile the closest project defined by a tsconfig. json , you can compile a set of TypeScript files by passing in a glob of files you want.

Does TSC come with TypeScript?

Install the TypeScript compiler# Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript ( tsc HelloWorld.


1 Answers

Not that I know of. Using tsc from the command line without a tsconfig.json requires that you specify each file individually, like so:

tsc MyFile1.ts MyFile2.ts MyFile3.ts 

However, it looks like you can simply create an empty tsconfig.json (i.e. just {}) at the root of your TypeScript directory and it will do what you want. From https://github.com/Microsoft/TypeScript/wiki/tsconfig.json:

If no "files" property is present in a tsconfig.json, the compiler defaults to including all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories.

like image 59
Nathan Friend Avatar answered Sep 28 '22 02:09

Nathan Friend