@@ -5606,18 +5606,31 @@ namespace ts {
56065606 return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
56075607 }
56085608
5609+ function isMatchingSignature(source: Signature, target: Signature, partialMatch: boolean) {
5610+ // A source signature matches a target signature if the two signatures have the same number of required,
5611+ // optional, and rest parameters.
5612+ if (source.parameters.length === target.parameters.length &&
5613+ source.minArgumentCount === target.minArgumentCount &&
5614+ source.hasRestParameter === target.hasRestParameter) {
5615+ return true;
5616+ }
5617+ // A source signature partially matches a target signature if the target signature has no fewer required
5618+ // parameters and no more overall parameters than the source signature (where a signature with a rest
5619+ // parameter is always considered to have more overall parameters than one without).
5620+ if (partialMatch && source.minArgumentCount <= target.minArgumentCount && (
5621+ source.hasRestParameter && !target.hasRestParameter ||
5622+ source.hasRestParameter === target.hasRestParameter && source.parameters.length >= target.parameters.length)) {
5623+ return true;
5624+ }
5625+ return false;
5626+ }
5627+
56095628 function compareSignatures(source: Signature, target: Signature, partialMatch: boolean, ignoreReturnTypes: boolean, compareTypes: (s: Type, t: Type) => Ternary): Ternary {
56105629 if (source === target) {
56115630 return Ternary.True;
56125631 }
5613- if (source.parameters.length !== target.parameters.length ||
5614- source.minArgumentCount !== target.minArgumentCount ||
5615- source.hasRestParameter !== target.hasRestParameter) {
5616- if (!partialMatch ||
5617- source.parameters.length < target.parameters.length && !source.hasRestParameter ||
5618- source.minArgumentCount > target.minArgumentCount) {
5619- return Ternary.False;
5620- }
5632+ if (!(isMatchingSignature(source, target, partialMatch))) {
5633+ return Ternary.False;
56215634 }
56225635 let result = Ternary.True;
56235636 if (source.typeParameters && target.typeParameters) {
0 commit comments