Inferences from type aliases disregard variance #31659
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 3.5.0 and previous
Code
// @strictFunctionTypes: true
type Func<T> = (x: T) => void;
declare let f1: Func<string>;
declare let f2: Func<"a">;
declare function foo<T>(f1: Func<T>, f2: Func<T>): void;
foo(f1, f2); // ErrorExpected behavior:
No error.
Actual behavior:
Error.
When inferring between instantiations of the same type alias we always make covariant inferences instead of computing and using proper variance information.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Activity
jcalz commentedon May 29, 2019
Possibly duplicate of or related to #31251 and #31295?
ahejlsberg commentedon May 29, 2019
No, I don't think either of those are related.
jcalz commentedon May 29, 2019
Okay (Joe Calzaretta (@jcalz) slinks away)