Closed
Description
Bug Report
If I have strictPropertyInitialization
set to true
in tsconfig.json I expect that it would be an error if there is no initializer for a property.
🔎 Search Terms
strictPropertyInitialization
undefined
initializer
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
class C {
// @ts-expect-error Missing initializer
x: number | undefined;
}
🙁 Actual behavior
No compile error
🙂 Expected behavior
I expect there to be a compile error because instances of this class will not have an x
property.
Always initializing properties in a fixed order is important to ensure all instances end up with the sam hidden class in a lot of JS VMs.