HomeAbout

Compiling

What is tsc

What is compile in TS?

Compiling in Typescript is direct translation of .ts files to .js files.

tsc processes each file independently and generates corresponding .js files for each.

What is build in TS?

TypeScript compiler can orchestrate the compilation of an entire project, including handling dependencies between files and projects.

Compiling using tsc

Compile typescript locally on a project using Typescript Compiler (tsc).

Running tsc locally will compile the closest project defined by a tsconfig.json:

# Compile entire project (actually builds it) tsc -b # Compile specific file tsc -b path/index.ts # do not emit compiler output files tsc --noEmit # all `.ts` files in given path tsc src/*.ts # clean builds tsc -b --clean

Scope Issue of tsc

Running tsc on a given path will still check the adjacent/neighboring types that are used in the current context.

  • Makes sense since you need all type definitions consumed to compile to the fullest type definitions.

If you want to truly isolate the tsc run to a specified scope, check nx affected.

IDL

Interface Definition Language

AboutContact