-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
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 errorExpected 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
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone