Fix bug: getNonNullableType before getting signatures of method (#21212)
This commit is contained in:
parent
004f18ff0c
commit
c549bb5737
2 changed files with 9 additions and 1 deletions
|
@ -15815,7 +15815,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
function isValidMethodAccess(method: Symbol, type: Type) {
|
function isValidMethodAccess(method: Symbol, type: Type) {
|
||||||
const propType = getTypeOfFuncClassEnumModule(method);
|
const propType = getTypeOfFuncClassEnumModule(method);
|
||||||
const signatures = getSignaturesOfType(propType, SignatureKind.Call);
|
const signatures = getSignaturesOfType(getNonNullableType(propType), SignatureKind.Call);
|
||||||
Debug.assert(signatures.length !== 0);
|
Debug.assert(signatures.length !== 0);
|
||||||
return signatures.some(sig => {
|
return signatures.some(sig => {
|
||||||
const thisType = getThisTypeOfSignature(sig);
|
const thisType = getThisTypeOfSignature(sig);
|
||||||
|
|
8
tests/cases/fourslash/completionsOptionalMethod.ts
Normal file
8
tests/cases/fourslash/completionsOptionalMethod.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/// <reference path="fourslash.ts" />
|
||||||
|
|
||||||
|
// @strictNullChecks: true
|
||||||
|
|
||||||
|
////declare const x: { m?(): void };
|
||||||
|
////x./**/
|
||||||
|
|
||||||
|
verify.completionsAt("", ["m"]);
|
Loading…
Reference in a new issue