liveBook · Manning

Tsconfig.json

As explained in Secrets of the JavaScript Ninja, Third Edition

A JSON configuration file that specifies TypeScript compiler inputs, type libraries, checking settings, emission behavior, and the target ECMAScript version.

A tsconfig.json file tells the TypeScript compiler which files to compile, which types to include, how strictly to check them, whether to emit JavaScript, and which ECMAScript version to target. section 2.1.1

$ npx tsc --init
 
Created a new tsconfig.json with:
 
  target: es2016
  module: commonjs
  strict: true
  esModuleInterop: true
  skipLibCheck: true
  forceConsistentCasingInFileNames: true

Generate a starter configuration with `npx tsc --init`; its shown defaults include ES2016, CommonJS, and strict checking. section 2.1.1

Without overrides, `tsc` checks and compiles all `.ts` files in the project. A type error does not prevent JavaScript emission: the faulty `setTimeout(200, ...)` example still produces output. section 2.1.1

JavaScript files checked with `@ts-check` can receive editor type feedback without being included in the build defined by tsconfig.json. section 2.2.1

How Secrets of the JavaScript Ninja, Third Edition covers it

How deep it goes
Defines key compiler settings and demonstrates starter generation and default compilation, while deferring comprehensive option guidance.
Examples
Uses generated compiler defaults, a faulty setTimeout call, and JavaScript checked with @ts-check.
What it assumes
Walks through creating a project directory and installing TypeScript, but defers details of npm.
What you can do after
Operate/configure a TypeScript project by generating tsconfig.json and running tsc to check and emit included files.
How it connects
Connects TypeScript compilation and type checking with ECMAScript targets and ESLint’s type-aware rules.

Also explained in

Compare how 2 books explain tsconfig.json →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Third Edition. The section links point to the parts of the book it draws on.