-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option for strictPropertyInitialization to check even potentially undefined properties #26015
Comments
IIRC control flow analysis only happens when In addition |
Given: class C {
x: number | undefined;
y: number;
} There will be an error at |
"This PR implements a new --strictPropertyInitialization compiler option to guard against uninitialized properties in class instances". E.g., with --strictPropertyInitialization but without --strictNullChecks: Given: class C {
x: number | undefined;
y: number;
} there should be an error in both. Given: class C {
x: number | undefined = undefined;
y: number = undefined;
} no errors. This is the compiler option I'm looking for, and this is the behavior I thought --strictPropertyInitialization had. |
Should I open a proposal for a new compiler option? |
Let's just make that this issue. |
Would prefer not to add another commandline flag or induce a big breaking change. |
Opening new bug since the previous got closed without any explanation.
Why strictPropertyInitialization should require strictNullChecks?
Without stringNullChecks, I can solve the error explicitly assigning undefined to baz.
The text was updated successfully, but these errors were encountered: