diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts
index 3e696435aa967..0b240648a7b17 100644
--- a/src/services/codefixes/fixAddMissingMember.ts
+++ b/src/services/codefixes/fixAddMissingMember.ts
@@ -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);
}
}
diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts
index 4e91a28dafadc..b3f77d098e5a9 100644
--- a/src/services/codefixes/helpers.ts
+++ b/src/services/codefixes/helpers.ts
@@ -252,7 +252,7 @@ namespace ts.codefix {
context: CodeFixContextBase,
importAdder: ImportAdder,
call: CallExpression,
- name: Identifier,
+ name: Identifier | string,
modifierFlags: ModifierFlags,
contextNode: Node
) {
diff --git a/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration17.ts b/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration17.ts
new file mode 100644
index 0000000000000..53c88c9ef7297
--- /dev/null
+++ b/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration17.ts
@@ -0,0 +1,17 @@
+///
+
+////// 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.");
+}
+`
+});
diff --git a/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration18.ts b/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration18.ts
new file mode 100644
index 0000000000000..4a7fa06887d4a
--- /dev/null
+++ b/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration18.ts
@@ -0,0 +1,21 @@
+///
+
+/////**
+//// * 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.");
+}
+`
+});