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
{{ message }}
Repository navigation
Switch on typeof for keyof type loses information #27181
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).
Activity
ahejlsberg commentedon Sep 18, 2018
This one is fixed by #27157.
jack-williams commentedon Sep 18, 2018
Great, I'll remove the fix I put in for #27182 (but will keep the tests). This will mean #27182 is blocked on #27157 but that seems ok I think.