Skip to content

Compiler error when using type aliased return values on down-level async functions #12776

@azz

Description

@azz

TypeScript Version: 2.1.1

Target ES5.

Code

// OK
async function foo(): Promise<boolean> {
    return Promise.resolve(true);
}

// NOT OK (?)
type AsyncBool = Promise<boolean>;
async function bar(): AsyncBool {
    return Promise.resolve(true);
}

Expected behavior:

Successful compilation.

Actual behavior:

Compiler error:

Type 'AsyncBool' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.

See playground demo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions