-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Suboptimal inference to unions like T | Promise<T> #32434
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.6.0-dev
Code
declare function foo<T>(x: T | Promise<T>): void;
declare let x: false | Promise<true>;
foo(x); // Error, 'false | Promise<true>' not assignable to 'true | Promise<true>'
declare function bar<T>(x: T, y: string | T): T;
const y = bar(1, 2); // Error, '2' not assignable to 'string | 1'Expected behavior: No errors.
Actual behavior: Errors as noted above.
Related Issues: Discovered in #32386.
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