-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
BugA bug in TypeScriptA bug in TypeScript
Milestone
Description
Bug Report
Optional discriminated union's callback parameter type is not inferred
π Search Terms
π Version & Regression Information
β― Playground Link
π» Code
type A = {
type?: 'A',
a: (c: { d: number }) => void;
}
type B = {
type: 'B',
a: (c: { d: number, c: string }) => void;
}
type ABC = A | B ;
var a: ABC[] | Record<string, ABC[]> = [
{
a: (params) => {
}
}
]
π Actual behavior
Parameters of method 'a' can not be inferred correctly.
π Expected behavior
Parameters of method 'a 'can be inferred correctly: {d: number}
Eldemarkki and kizu
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript