2025-03-14 21:59:59 -06:00
# tsc
> TypeScript compiler.
> More information: <https://www.typescriptlang.org/docs/handbook/compiler-options.html>.
2025-12-16 10:20:31 -07:00
- Initialize a TypeScript project:
2025-03-14 21:59:59 -06:00
2025-12-16 10:20:31 -07:00
`tsc --init`
- Compile a TypeScript file into a JavaScript file with the same name:
`tsc {{path/to/file.ts}}`
2025-03-14 21:59:59 -06:00
- Compile a TypeScript file into JavaScript using a specific target syntax (default is `ES3` ):
2025-12-16 10:20:31 -07:00
`tsc {{[-t|--target]}} {{ES5|ES2015|ES2016|ES2017|ES2018|ESNEXT|...}} {{path/to/file.ts}}`
2025-03-14 21:59:59 -06:00
- Compile a TypeScript file into a JavaScript file with a custom name:
2025-12-16 10:20:31 -07:00
`tsc --outFile {{path/to/output_file.js}} {{path/to/input_file.ts}}`
2025-03-14 21:59:59 -06:00
2025-12-16 10:20:31 -07:00
- Compile all `.ts` files of a TypeScript project defined in a `tsconfig.json` file (`--build` can be omitted to build the project in the current working directory):
2025-03-14 21:59:59 -06:00
2025-12-16 10:20:31 -07:00
`tsc {{[-b|--build]}} {{path/to/tsconfig.json}}`
2025-03-14 21:59:59 -06:00
- Run the compiler using command-line options and arguments fetched from a text file:
`tsc @{{args.txt}}`
- Type-check multiple JavaScript files, and output only the errors:
`tsc --allowJs --checkJs --noEmit {{src/**/*.js}}`
- Run the compiler in watch mode, which automatically recompiles code when it changes:
2025-12-16 10:20:31 -07:00
`tsc {{[-w|--watch]}}`