You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionf1(a?: {}) : {}{constn=null??{};a??=n;returna;// no problem}functionf2(a?: {}) : {}{a??=(null??{});returna;// Type '{} | undefined' is not assignable to type '{}'.}functionidentityFunction<T>(a: T): T{returna;}functionf3(a?: {}) : {}{a??=identityFunction(null??{});returna;// also fine}
🙁 Actual behavior
On line 9, a type error is reported: "Type '{} | undefined' is not assignable to type '{}'."
🙂 Expected behavior
I would expect that the code should pass type checking. Here's why.
1 . ??= generally supports narrowing types, as shown in the playground link.
2. ?? generally supports nullability narrowing, as shown in the playground link.
3. There's nothing special about a RHS of a ??= that contains a ??.
The text was updated successfully, but these errors were encountered:
I'm trying to look through the codebase to learn about it and how to fix this issue, and stumbled across these cases as well. Don't want to open a new work item since they are so closely related. Let me know if there is a better procedure to report this.
Bug Report
🔎 Search Terms
Control-Flow-Analysis Coalescing
🕗 Version & Regression Information
??=
wasn't supported.⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
On line 9, a type error is reported: "Type '{} | undefined' is not assignable to type '{}'."
🙂 Expected behavior
I would expect that the code should pass type checking. Here's why.
1 .
??=
generally supports narrowing types, as shown in the playground link.2.
??
generally supports nullability narrowing, as shown in the playground link.3. There's nothing special about a RHS of a
??=
that contains a??
.The text was updated successfully, but these errors were encountered: