mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-23 12:55:05 -05:00
fix duplicate async modifier codefix
This commit is contained in:
@@ -15,11 +15,14 @@ namespace ts.codefix {
|
||||
return [createCodeFixAction(fixId, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId, Diagnostics.Add_all_missing_async_modifiers)];
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const nodes = getNodes(diag.file, diag.start);
|
||||
if (!nodes) return;
|
||||
doChange(changes, context.sourceFile, nodes);
|
||||
}),
|
||||
getAllCodeActions: context => {
|
||||
const seen = createMap<true>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const nodes = getNodes(diag.file, diag.start);
|
||||
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore))) return;
|
||||
doChange(changes, context.sourceFile, nodes);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
function getReturnType(expr: FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction) {
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
////function f() {
|
||||
//// await Promise.resolve();
|
||||
//// await Promise.resolve();
|
||||
////}
|
||||
////
|
||||
////const g = () => {
|
||||
//// await f();
|
||||
//// await f();
|
||||
////}
|
||||
|
||||
verify.codeFixAll({
|
||||
@@ -14,9 +16,11 @@ verify.codeFixAll({
|
||||
newFileContent:
|
||||
`async function f() {
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
}
|
||||
|
||||
const g = async () => {
|
||||
await f();
|
||||
await f();
|
||||
}`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user