- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
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.6.3
Search Terms: promise all
Code
type MaybePromise<T> = T | Promise<T> | PromiseLike<T>
function MaybePromise<T>(value: T): MaybePromise<T> {
    return Promise.resolve(value)
}
async function main() {
    let aaa: number
    let bbb: string
    [
        aaa,
        bbb,
    ] = await Promise.all([
        MaybePromise(1),
        MaybePromise('2'),
        MaybePromise(true),
    ])
}tsconfig:
{
  "compilerOptions": {
    "strict": true,
    "target": "es5",
    "module": "commonjs",
    "lib": [
      "es6"
    ]
  }
Expected behavior:
Code should compile without errors.
Actual behavior:
Error:
test.ts:11:9 - error TS2322: Type 'number | Promise<1>' is not assignable to type 'number'.
  Type 'Promise<1>' is not assignable to type 'number'.
test.ts:12:9 - error TS2322: Type 'string | Promise<"2">' is not assignable to type 'string'.
  Type 'Promise<"2">' is not assignable to type 'string'.
Code compiles well with 3.5.3, but not 3.6.3 nor 3.7.0-dev.20190922.
Playground Link:
Weirdly enough, on the playground the return value of Promise.all is not a tuple but a list.
Related Issues:
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