Skip to content

Async function return type issue #5165

@jamiewinder

Description

@jamiewinder

There appears to be a typing bug with the return values from async functions, perhaps limited to tuples. Examples:

// Works!
function test(): [boolean, number] {
    return [true, 1];
}

// Works!
function test2(): Promise<[boolean, number]> {
    return Promise.resolve([true, 1]);
}

// Doesn't work
async function test3(): Promise<[boolean, number]> {
    return [true, 1]; // Error here!
}

The error is:

Type '(boolean | number)[]' is not assignable to type '[boolean, number]'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions