Skip to content

Commit 0f6f857

Browse files
committed
Allow contextual signature to be generic
1 parent 9e613b9 commit 0f6f857

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13042,13 +13042,13 @@ namespace ts {
1304213042
return node ? node.contextualMapper : identityMapper;
1304313043
}
1304413044

13045-
// If the given type is an object or union type, if that type has a single signature, and if
13046-
// that signature is non-generic, return the signature. Otherwise return undefined.
13047-
function getNonGenericSignature(type: Type, node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature {
13045+
// If the given type is an object or union type with a single signature, and if that signature has at
13046+
// least as many parameters as the given function, return the signature. Otherwise return undefined.
13047+
function getContextualCallSignature(type: Type, node: FunctionExpression | ArrowFunction | MethodDeclaration): Signature {
1304813048
const signatures = getSignaturesOfStructuredType(type, SignatureKind.Call);
1304913049
if (signatures.length === 1) {
1305013050
const signature = signatures[0];
13051-
if (!signature.typeParameters && !isAritySmaller(signature, node)) {
13051+
if (!isAritySmaller(signature, node)) {
1305213052
return signature;
1305313053
}
1305413054
}
@@ -13099,12 +13099,12 @@ namespace ts {
1309913099
return undefined;
1310013100
}
1310113101
if (!(type.flags & TypeFlags.Union)) {
13102-
return getNonGenericSignature(type, node);
13102+
return getContextualCallSignature(type, node);
1310313103
}
1310413104
let signatureList: Signature[];
1310513105
const types = (<UnionType>type).types;
1310613106
for (const current of types) {
13107-
const signature = getNonGenericSignature(current, node);
13107+
const signature = getContextualCallSignature(current, node);
1310813108
if (signature) {
1310913109
if (!signatureList) {
1311013110
// This signature will contribute to contextual union signature

0 commit comments

Comments
 (0)