fix(49392): show optional class methods with enabled strict option (#49768)

This commit is contained in:
Oleksandr T 2022-07-19 00:49:13 +03:00 committed by GitHub
parent efbe03a33c
commit 91f7cfc501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -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;
}

View File

@ -0,0 +1,29 @@
/// <reference path="fourslash.ts" />
// @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}"
},
],
});