Bug Report
🔎 Search Terms
generics overload
🕗 Version & Regression Information
- 4.7.4(current), 4.8.0-beta(beta)
⏯ Playground Link
Playground link with relevant code
💻 Code
typeA1<T>={type: "a1",v: T};typeB1<T>={type: "b1",v: T};typeA2={a2: string};typeB2={b2: string};functionfn<T>(p1: (pp1: 0)=>A1<T>,p2: (pp2: A2)=>0): void;functionfn<T>(p1: (pp1: 0)=>B1<T>,p2: (pp2: B2)=>0): void;functionfn<T>(p1:
|((pp1: 0)=>A1<T>)|((pp1: 0)=>B1<T>),p2:
|((pp2: A2)=>0)|((pp2: B2)=>0)){}constvalA1: A1<string>=({type: "a1",v: ""});constvalB1: B1<string>=({type: "b1",v: ""});// expect Afn((ap1)=>valA1,(ap2)=>0);fn((ap1)=>valA1,(ap2: A2)=>0);fn((ap1)=>valA1,(ap2: any)=>0);fn((ap1)=>valA1,(ap2: unknown)=>0);fn((ap1: 0)=>valA1,(ap2)=>0);// expect Bfn((bp1)=>valB1,(bp2)=>0);// but it will be A, only this will result in an errorfn((bp1)=>valB1,(bp2: B2)=>0);fn((bp1)=>valB1,(bp2: any)=>0);fn((bp1)=>valB1,(bp2: unknown)=>0);fn((bp1: 0)=>valB1,(bp2)=>0);🙁 Actual behavior
No overload matches this call.
Overload 1 of 2, '(p1: (pp1: 0) => A1<string>, p2: (pp2: A2) => 0): void', gave the following error.
Type 'B1<string>' is not assignable to type 'A1<string>'.
Types of property 'type' are incompatible.
Type '"b1"' is not assignable to type '"a1"'.
Overload 2 of 2, '(p1: (pp1: 0) => B1<string>, p2: (pp2: B2) => 0): void', gave the following error.
Argument of type '(bp2: A2) => 0' is not assignable to parameter of type '(pp2: B2) => 0'.
Types of parameters 'bp2' and 'pp2' are incompatible.
Property 'a2' is missing in type 'B2' but required in type 'A2'.(2769)
🙂 Expected behavior
No errors
Bug Report
🔎 Search Terms
generics overload
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
No errors