Closed
Description
TypeScript Version: >3.9.2
Search Terms: generic argument inference TS2345
Code
declare namespace React {
type WeakValidationMap<T> = {
[K in keyof T]?: null extends T[K] ? string : string
};
interface FunctionComponent<P = {}> {
propTypes?: WeakValidationMap<P>;
}
}
type A<T1> = <T2>() => React.FunctionComponent<T1 & T2>;
function B<T>(_: A<T>) {}
interface C {
r: String;
}
function myFunction<T2>(): React.FunctionComponent<C & T2> {
return {};
}
B(myFunction) // Error
B<C>(myFunction) // No error
Expected behavior: In v3.8.3, the code above did not have any compilation error.
Actual behavior: Compilation error TS2345 when I do not explicitly pass the generic type.
Playground Link: Link
Note: I use React, here I only included the minimal React interfaces to reproduce the issue. The issue is also reproducible with React code directly here