strict (compiler option)
The strict compiler option, which turns on a family of stronger checks such as strictNullChecks and noImplicitAny in one setting.
In more detail
Every new project should enable it, and since TypeScript 6.0 it is on by default. It makes null and undefined explicit, forbids silently untyped parameters and tightens function checks. Not to be confused with JavaScript's "use strict" directive, which is a different run time mode.
Example
"strict": trueRelated terms
- strictNullChecks — The compiler option that makes null and undefined separate types, so you must handle them before using a value.
- noImplicitAny — The compiler option, included in strict mode, that reports an error when the compiler cannot work out a type and would silently fall back to any.
- tsconfig.json — The configuration file that tells the TypeScript compiler which files to check and how strict to be.
- greenfield project — A brand-new project with no existing code, so you can choose the strictest settings from the start.
Taught in
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript
- The Spine Artifact: Generating Typed Models From OpenAPI — Production TypeScript