mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
fix(43006): skip trivia in a function name (#43021)
This commit is contained in:
parent
7b14d41642
commit
47b2632ddd
@ -402,7 +402,7 @@ namespace ts.codefix {
|
||||
|
||||
function addFunctionDeclaration(changes: textChanges.ChangeTracker, context: CodeFixContextBase, info: FunctionInfo) {
|
||||
const importAdder = createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
||||
const functionDeclaration = createSignatureDeclarationFromCallExpression(SyntaxKind.FunctionDeclaration, context, importAdder, info.call, info.token, info.modifierFlags, info.parentDeclaration) as FunctionDeclaration;
|
||||
const functionDeclaration = createSignatureDeclarationFromCallExpression(SyntaxKind.FunctionDeclaration, context, importAdder, info.call, idText(info.token), info.modifierFlags, info.parentDeclaration) as FunctionDeclaration;
|
||||
changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ namespace ts.codefix {
|
||||
context: CodeFixContextBase,
|
||||
importAdder: ImportAdder,
|
||||
call: CallExpression,
|
||||
name: Identifier,
|
||||
name: Identifier | string,
|
||||
modifierFlags: ModifierFlags,
|
||||
contextNode: Node
|
||||
) {
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////// comment
|
||||
////foo();
|
||||
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
|
||||
newFileContent:
|
||||
`// comment
|
||||
foo();
|
||||
|
||||
function foo() {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
`
|
||||
});
|
||||
@ -0,0 +1,21 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////**
|
||||
//// * comment
|
||||
//// */
|
||||
////foo();
|
||||
|
||||
verify.codeFix({
|
||||
index: 0,
|
||||
description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"],
|
||||
newFileContent:
|
||||
`/**
|
||||
* comment
|
||||
*/
|
||||
foo();
|
||||
|
||||
function foo() {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
`
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user