A class field declared with a type, such as /** @type {string} */ owner;, promises that every instance has a string there. strictPropertyInitialization checks the promise: the field needs an initializer (owner = "";) or an assignment in the constructor. If it has neither, it starts out undefined, and TypeScript reports TS2564.
It is part of strict, arrived with TypeScript 2.7, and needs strictNullChecks, which strict also turns on.
At a glance
| Write | Leave it to strict; write "strictPropertyInitialization": false only to turn this one check back off |
|---|---|
| On the command line | --strictPropertyInitialization |
| Type | boolean |
| Default in TypeScript 5.9 | false (on when strict is on) |
| Default from TypeScript 6.0 | true, through strict (TypeScript 6.0) |
| TypeScript's description | Check for class properties that are declared but not set in the constructor. |
The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.
Examples
export class Account {
/** @type {string} */
owner;error TS2564: Property 'owner' has no initializer and is not definitely assigned in the constructor.
/** @type {number} */
balance;
constructor() {
this.balance = 0;
}
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} export class Account {
/** @type {string} */
owner;
/** @type {number} */
balance;
constructor() {
this.balance = 0;
}
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [],
"strictPropertyInitialization": false
},
"include": [
"*.js"
]
} Three ways to fix it
In a .js file:
- give the field a value:
owner = ""; - assign it in the constructor, as the example does for
balance - say it may be missing:
/** @type {string | undefined} */ owner;
Properties set only in the constructor
Many JavaScript classes never declare fields; they assign this.owner = owner in the constructor, and TypeScript infers the property from that. Such properties are always set, so this check has nothing to report about them.
Gotchas
- TypeScript files can write
owner!: stringto say "set elsewhere". JavaScript has no such syntax; use one of the fixes above. - Without
strictNullChecksthe option is a config error.
Sources
- TSConfig Reference: strictPropertyInitialization · TypeScript
- TypeScript 2.7 release notes · TypeScript handbook
- Type Checking JavaScript Files · TypeScript handbook
Last reviewed 20 October 2026.