-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Has ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Description
TypeScript Version: 4.1.0-beta
Search Terms:
promise promiselike instanceof
Code
declare const p: PromiseLike<number>;
const p1 = p instanceof Promise ? p : Promise.resolve(p);
const p2: Promise<number> = p1.then((v) => v + 1);
Expected behavior:
No errors.
Actual behavior:
p2 errors because the expression has been determined to be promise-like.
Also p1 is inferred as PromiseLike & Promise.
Related Issues:
Metadata
Metadata
Assignees
Labels
Has ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.