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
functionkeyofNarrowing<Sextends{[KinkeyofS]: string}>(k: keyofS){switch(typeofk){case'number': k;return;// k has type number, should be keyof S & numbercase'symbol': k;return;// k has type number, should be keyof S & symbolcase'string': k;return;// k has type number, should be keyof S & string}}
Expected behavior:
The value k should narrow to an intersection type to retain keyof type.
Actual behavior:
The value k narrows to a primitive.
Playground Link: N/A (Playground not on this version).
The text was updated successfully, but these errors were encountered:
TypeScript Version: master 83fe1ea
Search Terms: switch typeof keyof intersection
Code
Expected behavior:
The value
k
should narrow to an intersection type to retainkeyof
type.Actual behavior:
The value
k
narrows to a primitive.Playground Link: N/A (Playground not on this version).
The text was updated successfully, but these errors were encountered: