Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Command

tsc

tsc is the TypeScript compiler command. Run it with no inputs to build the nearest configured project, or provide files and compiler options for a direct compilation.

How it works

The tsc command invokes the TypeScript compiler. With no input files, it uses the nearest project configuration; with file paths supplied, it compiles those inputs directly and ignores tsconfig.json files.

Syntax

tsc [options] [file ...]

Parameters

NameTypeDescription
filesstring[]Optional source files or glob patterns to compile.
--project, -pstringPath to a tsconfig.json file or a directory containing one.

Returns

Emits JavaScript and related output according to the selected compiler options, or reports diagnostics; some options instead inspect configuration or file membership and stop without a normal build.

Key points

  • Running tsc without input files compiles the nearest configured project.
  • File paths or globs can be supplied to compile explicit inputs.
  • The --init option creates a starter project configuration.
  • Use --showConfig to inspect the resolved configuration without compiling.
  • Use --listFilesOnly to inspect which files belong to the compilation.
  • Use --all to display the complete CLI option list.

Common mistakes

  • Passing source files directly bypasses project configuration, so compiler settings from tsconfig.json do not apply.
  • Use --project or -p when you need to select a specific configured project.

Example: Compile a file with strict checking

tsc --strict --outDir dist src/index.ts

Compiles the specified TypeScript file with strict checking and writes emitted output under dist.

When to use it

Compile a configured project

Build a repository using its nearest tsconfig.json.

Perform a focused build

Compile selected files with command-line options.

Manage compiler configuration

Inspect or initialize project configuration.

  • tsconfig.json
  • --project
  • --init
  • --showConfig
  • --listFilesOnly
  • --all

Source: Documentation - tsc CLI Options. Checked 2026-10-15.