-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Declaring as object or undefined has problems in ts4.3 #44407
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
Comments
You forgot to fill out the issue template for bug reports.
Doesn't work in 4.2.3 either: Playground link Essentially a duplicate of #9998. |
Sorry about the missing template, it's my first report. And thanks for the quick response I too see that the Playground shows errors for 4.3, 4.2 and even 4.1. But if I paste this code into a project that is set up with 4.1, it works. So there seems to have been a change in 4.3 that takes it beyond #9998 |
Your other project may not have strictNullChecks enabled. |
Neither project has strictNullChecks enabled, but strict is true for the 4.2 project. Setting strict = true for 4.1 project give the same error, Looks like this is the cause. Has default behaviour of strict = true changed from 4.2 to 4.3? |
You see this behavior due to a fixed bug. See #44025. |
Thank you both for the swift response and for clearing up my confusion. Typescript rocks, keep up the excellent work! |
Bug Report
π Search Terms
Searched for 'undefined' in issues after 4.3
π Version & Regression Information
β― Playground Link
Note that the error is show for all 4.1, 4.2 and 4.3. But pasting the same code into a project using 4.1.5 does NOT show the error.
https://www.typescriptlang.org/play?ts=4.3.2&ssl=4&ssc=4&pln=17&pc=6#code/GYVwdgxgLglg9mABMOcAUBKRBvAUIgxAGwFMpEAHAJzgCNSBbALhwEMmwQHaSqBfRAB9E4ACYlgMMCVGIAvCLDjJ00QG5c+QqEiwEiAM5kAaqyIgSmPIRuUa9EgwXZ2ARgAMfDTb6abAen9EKhIjKC0CajpGeUVlKRkNCMRAxAgzIkQ4KAALXkQGMhy4WVzWcnSkUThEVjAAT1ypAHNksNNzSwwkmxhgRDQohwYsa1sCVIg4BgoYUipDVnqDRDLyAHIhxnXEGBWxCQTZOtkABRoKXih6xHXWHerQxDBsxBIADz3yfWvL2+kAG68dbJGxTMAGOCkAB0RDgzUG9kY0NYGGSvj4QA
π» Code
π Actual behavior
compiler says that 'problem' is undefined and Property 'a' does not exist on type 'never'
π Expected behavior
Expected compiler to know that 'problem could be both undefined and {a:number}
The text was updated successfully, but these errors were encountered: