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
Search Terms: Optional Chaining, Generic type, type information lost
While playing around on my side project, I found an edge case where optional chaining would fail to infer the correct types, while everything works fine without it.
Expected behavior: Line 30 yields no type error. Optional chaining narrows generic parameter down correctly and infers type {hello: "there", general: "kenobi} as in Line 23.
Actual behavior: TS yields error on line 29 and 30, data not in type 'A'. it seems like any type information of the generic type is lost.
TypeScript Version: 3.7.2
Search Terms: Optional Chaining, Generic type, type information lost
While playing around on my side project, I found an edge case where optional chaining would fail to infer the correct types, while everything works fine without it.
Expected behavior: Line 30 yields no type error. Optional chaining narrows generic parameter down correctly and infers type
{hello: "there", general: "kenobi}
as in Line 23.Actual behavior: TS yields error on line 29 and 30, data not in type 'A'. it seems like any type information of the generic type is lost.
Related Issues: #35274 #32735
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: