How To Compile All TypeScript Files in a Folder

Last updated on 25 Jan, 2023

If there is only one TypeScript file, we can compile the file using:

tsc app.ts

Above command will compile the app.ts file and generate app.js file.

What if there are two or more TypeScript files, app.ts and tag.ts? In that case, first initialize the folder as a TypeScript project.

tsc --init

Above command creates a tsconfig.json file in the project root. If you open the tsconfig.json file, you can find several options you can pass to TypeScript compiler.

Next, from the project root folder, just run tsc. No file name or nothing, just tsc. It will create .js files for all .ts files.

--- ○ ---
Joby Joseph
Web Architect