Skip to content

Commit 91f7cfc

Browse files
authored
fix(49392): show optional class methods with enabled strict option (microsoft#49768)
1 parent efbe03a commit 91f7cfc

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/services/codefixes/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace ts.codefix {
138138
// If there is more than one overload but no implementation signature
139139
// (eg: an abstract method or interface declaration), there is a 1-1
140140
// correspondence of declarations and signatures.
141-
const signatures = checker.getSignaturesOfType(type, SignatureKind.Call);
141+
const signatures = type.isUnion() ? flatMap(type.types, t => t.getCallSignatures()) : type.getCallSignatures();
142142
if (!some(signatures)) {
143143
break;
144144
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: a.ts
4+
// @strictNullChecks: true
5+
// @newline: LF
6+
7+
////interface IFoo {
8+
//// foo?(arg: string): number;
9+
////}
10+
////class Foo implements IFoo {
11+
//// /**/
12+
////}
13+
14+
verify.completions({
15+
marker: "",
16+
isNewIdentifierLocation: true,
17+
preferences: {
18+
includeCompletionsWithInsertText: true,
19+
includeCompletionsWithSnippetText: false,
20+
includeCompletionsWithClassMemberSnippets: true,
21+
},
22+
includes: [
23+
{
24+
name: "foo",
25+
sortText: completion.SortText.ClassMemberSnippets,
26+
insertText: "foo(arg: string): number {\n}"
27+
},
28+
],
29+
});

0 commit comments

Comments
 (0)