Using nullish coalescing with untyped field in constructor trigger TS7022 #55013
Labels
Help Wanted
You can do this
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Bug Report
Using nullish coalescing in a constructor to initialize a class member with no type annotation will result in a TS7022 error.
🔎 Search Terms
nullish
,coalescing
,7022
,??
, andts7022
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Attempting to compile the example code results in a TS7022 error:
'#parent' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
🙂 Expected behavior
The code should compile and
#parent
should be typed asNode
|null
.The text was updated successfully, but these errors were encountered: