-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do this
Milestone
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do this