TypeScript Strict Mode Guide
TypeScript's strict flag enables 8 type-checking options at once. Use the builder above to toggle individual strict flags and see exactly how they affect your tsconfig.json output.
tsconfig.json Visual Builder
Build your TypeScript configuration visually with explanations for every option. Start from a preset or customize from scratch.
Presets
Set the JavaScript language version for emitted output.
Specify what module code is generated.
Strategy for resolving import specifiers.
Library files to include in the compilation.
Enables: noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, noImplicitThis, alwaysStrict, useUnknownInCatchVariables
Additional (not included in strict)
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}7
Options set
ON
Strict mode
302
Bytes
Press Ctrl+Enter to copy
What does strict: true enable?
Setting "strict": true in tsconfig.json enables 8 flags: noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, noImplicitThis, alwaysStrict, and useUnknownInCatchVariables. Each flag catches a different category of bugs. New projects should always start with strict: true.
noImplicitAny vs strictNullChecks
noImplicitAny prevents variables from silently receiving the 'any' type when TypeScript cannot infer a more specific type. strictNullChecks makes null and undefined their own types, preventing you from assigning null to a string variable. Together, these two flags catch the majority of type-related bugs in real-world codebases.
Migrating to strict mode
To migrate an existing project: first set strict: false and enable individual flags one at a time, starting with noImplicitAny and strictNullChecks. Fix errors for each flag before enabling the next. Alternatively, enable strict: true and use // @ts-expect-error or 'as any' annotations to suppress errors temporarily, then fix them incrementally.
Beyond strict: extra strictness flags
Two popular flags are NOT included in strict: noUncheckedIndexedAccess adds undefined to index signature results (obj['key'] becomes string | undefined), and exactOptionalPropertyTypes distinguishes between optional properties and properties explicitly set to undefined. Both are recommended for maximum type safety.
Frequently Asked Questions
Should I always use strict: true?
Yes. Every new TypeScript project should start with strict: true. It catches more bugs at compile time and makes your code more maintainable. The TypeScript team recommends it as the baseline for all projects.
What is the difference between strict and individual strict flags?
strict: true is a shorthand that enables 8 individual flags at once. Setting strict: true and then setting one flag to false (e.g., strictNullChecks: false) is valid — the individual flag overrides. This lets you opt out of specific checks while keeping the rest.
Does strict mode make TypeScript slower?
Strict mode has minimal impact on compilation speed. The additional type checks run during the same pass as non-strict checks. The slight increase in compile time is vastly outweighed by the bugs caught before runtime.
Related Generate Tools
README Generator
Generate professional GitHub README.md files with badges, installation steps, usage examples, and more
robots.txt Generator
Generate robots.txt files with crawl rules for Googlebot, Bingbot, AI bots, and more — presets included
Zod Schema Generator
Generate Zod validation schemas from JSON — auto-detects emails, URLs, UUIDs, dates, and nested objects
Placeholder Image Generator
Generate custom placeholder images for wireframes, mockups, and prototyping with custom dimensions and colors