Codecademy Logo

TypeScript Configuration

Print Cheatsheet

VSCode TypeScript Errors

VSCode displays TypeScript errors in two places: inline and in the Problems panel. Viewing an error inline is convenient while coding, whereas the problems panel shows many problems at once.

Two code snippets, one showing an inline TypeScript error and one showing an error in the Problems Panel, both in VSCode.

TypeScript CLI

We can run TypeScript’s CLI with the tsc command. tsc can type check and transpile TypeScript files.

TypeScript CLI Flags

TypeScript’s tsc can command takes command line flags to alter its behavior. For instance, if we pass a flag like --noUnusedLocals, tsc will ensure that all defined variables are used.

Install TypeScript as a Dependency

Installing TypeScript in a project as a dependency allows the project to rely on a specific version of TypeScript.

Initializing a TypeScript project

After initializing a new TypeScript project with the --init flag, a tsconfig.json file will be created.

Configure a TypeScript project with JSON

The tsconfig.json file contains options that control how TypeScript behaves when type checking and transpiling TypeScript.

Using a TypeScript Configuration as a Base

The top-level tsconfig.json option extends allows using another TypeScript configuration as a base, which can be overridden by options defined in tsconfig.json.