Closed
Description
Search Terms:
Async, Await, Refactoring, Code Fix,
Code
function f() {
return Promise.resolve().then(x => 1).catch(x => "a").then(x => !!x);
}
Expected behavior:
The refactor generates the following code with a unique catch parameter.
async function f() {
let x_1: string | number;
try {
const x = await Promise.resolve();
x_1 = 1;
}
catch (x_2) {
x_1 = "a";
}
return !!x_1;
}
Actual behavior:
The refactor generates the following code with a conflicting catch parameter. "a" is not assigned to the correct x_1.
async function f() {
let x_1: string | number;
try {
const x = await Promise.resolve();
x_1 = 1;
}
catch (x_1) {
x_1 = "a";
}
return !!x_1;
}
Playground Link:
Related Issues: