diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 94b64e57ac9..edcfe0a960c 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -138,7 +138,7 @@ namespace ts.codefix { // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); + const signatures = type.isUnion() ? flatMap(type.types, t => t.getCallSignatures()) : type.getCallSignatures(); if (!some(signatures)) { break; } diff --git a/tests/cases/fourslash/completionsOverridingMethod14.ts b/tests/cases/fourslash/completionsOverridingMethod14.ts new file mode 100644 index 00000000000..37aeae70790 --- /dev/null +++ b/tests/cases/fourslash/completionsOverridingMethod14.ts @@ -0,0 +1,29 @@ +/// + +// @Filename: a.ts +// @strictNullChecks: true +// @newline: LF + +////interface IFoo { +//// foo?(arg: string): number; +////} +////class Foo implements IFoo { +//// /**/ +////} + +verify.completions({ + marker: "", + isNewIdentifierLocation: true, + preferences: { + includeCompletionsWithInsertText: true, + includeCompletionsWithSnippetText: false, + includeCompletionsWithClassMemberSnippets: true, + }, + includes: [ + { + name: "foo", + sortText: completion.SortText.ClassMemberSnippets, + insertText: "foo(arg: string): number {\n}" + }, + ], +});