Typescript: Generics are not propagated in higher order function with constraint

Created on 4 Sep 2019  路  2Comments  路  Source: microsoft/TypeScript


TypeScript Version: 3.5.2, 3.6.2


Search Terms:

Code

const fn = <T extends (param: any) => any>(t: T) => t;

// Workaround:
// const fn = <T extends <A>(param: any) => any>(t: T) => t;

const myGenericFn = <T>(t: T) => t;

// Expected: <T>(t: T) => T
// Actual: (t: any) => any
const result = fn(myGenericFn);
Bug Fix Available

Most helpful comment

Funny, I just fixed a related issue by actually fixing this. See #33228.

All 2 comments

Funny, I just fixed a related issue by actually fixing this. See #33228.

Already fixed in #33228.

Was this page helpful?
0 / 5 - 0 ratings