Open
Description
π Search Terms
- discriminated union inference
- union argument inference
π Version & Regression Information
- This is a compilation error in
tsserver 3.3.2
β― Playground Link
π» Code
type InferArg =
| [1, (a: number) => void]
| [2, (b: string) => void];
const arg: InferArg = [1, (a) => { }];
π Actual behavior
I get a compilation error:
Parameter 'a' implicitly has an 'any' type.(7006)
π Expected behavior
a
should be inferred to be a number
because I already passed 1
as the first tuple element. Type inference should be identical to this code:
type InferArg = [1, (a: number) => void];
const arg: InferArg = [1, (a) => { }];
Additional information about the issue
No response