K extends keyof ...
not being narrowed in a switch case
#31743
Labels
Duplicate
An existing issue was already created
TypeScript Version: 3.5.1
Search Terms:
extends keyof narrowing
infer not narrowing type
Code
Expected behavior:
In the switch case each case should narrow the type of
method
,args
andresult
. However, this doesn't happen.Actual behavior:
What's actually occurring is that in each switch case,
method
has the typeK extends "setName" | "setAge" | "setBirthday" | "getName" | "getAge" | "getBirthday"
. Its type is not being narrowed to one of the keys ofUser
. This problem also persist for theargs
andresult
variables. They're not being narrowed to their respective types.The text was updated successfully, but these errors were encountered: