Closed
Description
Bug Report
type GenericBinding<
F extends <T1>(value: T1) => any, // take a generic fn with T1 parameter
T2, // also accept a T2 parameter
> = F<T2>; // bind the generic of F to T2
This does not work, although #47607 claims to have solved #40542 which is essentially this.
Test:
function myfn<T1>(value: T1) {};
const assert1a: typeof myfn extends (<T>(value: T) => void) ? true : false = true;
const assert1b: (<T>(value: T) => void) extends typeof myfn ? true : false = true;
type Test = GenericBinding<typeof myfn, string>; // bind `T1` at `myfn` to `string`, should get `(value: string) => void`
const assert2a: Test extends ((value: string) => void) ? true : false = true;
const assert2b: ((value: string) => void) extends Test ? true : false = true;
const assert2c: Test extends (<T>(value: T) => void) ? true : false = false;
const assert2d: (<T>(value: T) => void) extends Test ? true : false = false; // broken
🔎 Search Terms
High order generics.
#40542
#47607
#37181
🕗 Version & Regression Information
4.6 till 4.9.
⏯ Playground Link
Playground link with relevant code
💻 Code
See above.
🙁 Actual behavior
Compiler error Type 'F' is not generic.ts(2315)
.
🙂 Expected behavior
Actual evaluation of generics.