Chapter 13. Configuration Options

Compiler options:

Types and modules and oh my!

tsc your way.

TypeScript is highly configurable and made to adapt to all common JavaScript usage patterns. It can work for projects ranging from legacy browser code to the most modern server environments.

Much of TypeScript’s configurability comes from its cornucopia of over 100 configuration options that can be provided via either:

  • Command-line (CLI) flags passed to tsc

  • “TSConfig” TypeScript configuration files

This chapter is not intended as a full reference for all TypeScript configuration options. Instead, I’d suggest treating this chapter as a tour of the most common options you’ll find yourself using. I’ve included just the ones that tend to be more useful and widely used for most TypeScript project setups. See aka.ms/tsc for a full reference on each of these options and more.

tsc Options

Back in Chapter 1, “From JavaScript to TypeScript”, you used tsc index.ts to compile an index.ts file. The tsc command can take in most of TypeScript’s configuration options as -- flags.

For example, to run tsc on an index.ts file and skip emitting an index.js file (so, only run type checking), pass the --noEmit flag:

tsc index.ts --noEmit

You can run tsc --help to get a list of commonly used CLI flags. The full list of tsc configuration options from aka.ms/tsc is viewable with tsc --all.

Pretty Mode

The tsc CLI has the ability to output in a “pretty” mode: stylized with colors and spacing to make ...

Get Learning TypeScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.