Skip to content

in async code fix, handle promise handler callbacks that return a promise #27112

Closed
@uniqueiniquity

Description

@uniqueiniquity

TypeScript Version: 3.1.0-dev.201xxxxx

Search Terms:
async, promise, code fix, code action, then

Code

function foo() {
    return Promise.resolve().then(_ => Promise.resolve(4 + 5)).then(y => y + 5);
}

Expected behavior:
Async code fix produces

async function foo() {
    await Promise.resolve();
    const y = await Promise.resolve(4 + 5);
    return y + 5;
}

Actual behavior:
Async code fix produces

async function foo() {
    await Promise.resolve();
    const y = Promise.resolve(4 + 5);
    return y + 5;
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions