-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 3.2.0-dev.20181004
Code
function f(b: boolean, pn: Promise<number>, ps: Promise<string>) {
return Promise.resolve().then(() => b ? pn : ps);
}Expected behavior:
No error.
Actual behavior:
Pyramid of doom error message:
src/a.ts:2:35 - error TS2345: Argument of type '() => Promise<string> | Promise<number>' is not assignable to parameter of type '(value: void) => string | PromiseLike<string>'.
Type 'Promise<string> | Promise<number>' is not assignable to type 'string | PromiseLike<string>'.
Type 'Promise<number>' is not assignable to type 'string | PromiseLike<string>'.
Type 'Promise<number>' is not assignable to type 'PromiseLike<string>'.
Types of property 'then' are incompatible.
Type '<TResult1 = number, TResult2 = never>(onfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<...>' is not assignable to type '<TResult1 = string, TResult2 = never>(onfulfilled?: ((value: string) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => PromiseLike<...>'.
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
2 return Promise.resolve().then(() => b ? pn : ps);
Related Issues: #20531
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript