mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Ignore optionality when skipping overloads
This commit is contained in:
parent
b4451b159c
commit
4e57f700d0
@ -11906,16 +11906,9 @@ namespace ts {
|
||||
|
||||
function isAritySmaller(sourceType: Type, target: Expression) {
|
||||
if (isFunctionExpressionOrArrowFunction(target) && isFunctionType(sourceType)) {
|
||||
let targetParameterCount = 0;
|
||||
for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
|
||||
const param = target.parameters[targetParameterCount];
|
||||
if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const sourceSignatures = getSignaturesOfType(sourceType, SignatureKind.Call);
|
||||
const sourceLengths = sourceSignatures.map(sig => !sig.hasRestParameter ? sig.parameters.length : Number.MAX_VALUE);
|
||||
return forEach(sourceLengths, len => len < targetParameterCount);
|
||||
return forEach(sourceLengths, len => len < target.parameters.length);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -122,8 +122,8 @@ module GenericParameter {
|
||||
>'' : ""
|
||||
|
||||
var r11 = foo6(<T>(x: T, y?: T) => ''); // any => string (+1 overload)
|
||||
>r11 : { (x: any): string; (x: any, y?: any): string; }
|
||||
>foo6(<T>(x: T, y?: T) => '') : { (x: any): string; (x: any, y?: any): string; }
|
||||
>r11 : any
|
||||
>foo6(<T>(x: T, y?: T) => '') : any
|
||||
>foo6 : <T>(cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; }
|
||||
><T>(x: T, y?: T) => '' : <T>(x: T, y?: T) => string
|
||||
>T : T
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user