strictPropertyInitialization — TypeScript compiler option
Checks that non-optional instance fields with non-undefined types are initialized at declaration or definitely assigned on constructor paths. Requires strictNullChecks when enabled. A definite-assignment assertion suppresses the check without initializing the runtime value. Default: inherits the effective strict setting (false when strict is omitted in 5.8.3). With the enforcing setting, the corrected example compiles; the comparison fixture triggers TS2564. Disabling this particular check accepts the comparison fixture. Observed corrected runtime output: 'ready'. Use two separate files as labeled, then run tsc -p tsconfig.json and node example.js in an isolated directory. Tested with TypeScript 5.8.3 and Node.js 22.16.0; not a single-file live editor example.
Formal Syntax & Structure
{ "compilerOptions": { "strictPropertyInitialization": true }}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| strictPropertyInitialization | boolean | Set explicitly to true or false; omission uses the default described above. |
Working Example
// File: tsconfig.json (JSON; omit this file-label comment){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "types": [], "noEmitOnError": true, "strict": true, "strictPropertyInitialization": true }, "files": [ "example.ts" ]}// File: example.tsclass Store { label: string; constructor(label: string) { this.label = label; } }console.log(new Store("ready").label);