You are viewing a free preview of this lesson.
Subscribe to unlock all 12 lessons in this course and every other course on LearningBro.
A well-configured TypeScript project is easier to maintain, produces fewer bugs, and provides a better developer experience. This lesson covers the tsconfig.json file in depth, recommended compiler options, linting with ESLint, declaration files, and strategies for migrating JavaScript projects to TypeScript.
The tsconfig.json file is the heart of every TypeScript project. It tells the compiler which files to include, what JavaScript version to target, and how strictly to check your code.
Generate a starter config with:
// npx tsc --init
The strict flag enables a family of strict type-checking options:
// tsconfig.json
// {
// "compilerOptions": {
// "strict": true
// }
// }
This enables:
strictNullChecks — null and undefined are not assignable to other typesstrictFunctionTypes — function parameter types are checked contravariantlystrictBindCallApply — bind, call, and apply are strictly checkedstrictPropertyInitialisation — class properties must be initialisednoImplicitAny — expressions and declarations with an implied any type cause errorsnoImplicitThis — this expressions with an implied any type cause errorsalwaysStrict — emits "use strict" in every fileuseUnknownInCatchVariables — catch variables are typed as unknownAlways use strict: true for new projects. It catches the most bugs and represents best practice.
Specifies the ECMAScript version for the emitted JavaScript:
// "target": "ES2020" — modern browsers and Node 14+
// "target": "ES2022" — top-level await, class fields
// "target": "ESNext" — latest features
Choose the lowest target that your runtime environment supports.
Specifies the module system for the emitted JavaScript:
// "module": "ESNext" — ES modules (recommended for bundlers)
// "module": "CommonJS" — require/module.exports (Node.js legacy)
// "module": "NodeNext" — Node.js native ESM support
Controls how TypeScript resolves module import paths:
// "moduleResolution": "bundler" — for Vite, webpack, etc.
// "moduleResolution": "node" — classic Node.js resolution
// "moduleResolution": "nodenext" — Node.js ESM resolution
Here is a recommended configuration for a modern TypeScript project:
Subscribe to continue reading
Get full access to this lesson and all 12 lessons in this course.