-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Code
type Test<V, M extends boolean> = { multiple?: M } & (
M extends true ? { values: V[] } : { value: V }
)
function typeGuard<V, M extends boolean>(input: Test<V, M>) {
if (input.multiple) {
return input.values;
} else {
return input.value;
}
}
Expected behavior:
input.values
can be inferred in if
block and input.value
can be inferred in else
block.
Actual behavior:
Property 'values' does not exist on type 'Test<V, M>'.
Property 'value' does not exist on type 'Test<V, M>'.
Related Issues:
Kingwl
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug