Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19805,6 +19805,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
(checkMode & SignatureCheckMode.StrictArity ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
if (sourceHasMoreParameters) {
if (reportErrors && !(checkMode & SignatureCheckMode.StrictArity)) {
// the second condition should be redundant, because there is no error reporting when comparing signatures by strict arity
// since it is only done for subtype reduction
errorReporter!(Diagnostics.Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1, getMinArgumentCount(source), targetCount);
}
return Ternary.False;
}

Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3619,6 +3619,10 @@
"category": "Error",
"code": 2848
},
"Target signature provides too few arguments. Expected {0} or more, but got {1}.": {
"category": "Error",
"code": 2849
},

"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tests/cases/compiler/addMoreOverloadsToBaseSignature.ts(5,11): error TS2430: Interface 'Bar' incorrectly extends interface 'Foo'.
Types of property 'f' are incompatible.
Type '(key: string) => string' is not assignable to type '() => string'.
Target signature provides too few arguments. Expected 1 or more, but got 0.


==== tests/cases/compiler/addMoreOverloadsToBaseSignature.ts (1 errors) ====
Expand All @@ -13,6 +14,7 @@ tests/cases/compiler/addMoreOverloadsToBaseSignature.ts(5,11): error TS2430: Int
!!! error TS2430: Interface 'Bar' incorrectly extends interface 'Foo'.
!!! error TS2430: Types of property 'f' are incompatible.
!!! error TS2430: Type '(key: string) => string' is not assignable to type '() => string'.
!!! error TS2430: Target signature provides too few arguments. Expected 1 or more, but got 0.
f(key: string): string;
}

4 changes: 4 additions & 0 deletions tests/baselines/reference/arrowFunctionErrorSpan.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tests/cases/compiler/arrowFunctionErrorSpan.ts(17,3): error TS2345: Argument of
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(18,5): error TS1200: Line terminator not permitted before arrow.
tests/cases/compiler/arrowFunctionErrorSpan.ts(21,3): error TS2345: Argument of type '(a: any, b: any, c: any, d: any) => void' is not assignable to parameter of type '() => number'.
Target signature provides too few arguments. Expected 4 or more, but got 0.
tests/cases/compiler/arrowFunctionErrorSpan.ts(28,7): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(32,7): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Expand All @@ -17,6 +18,7 @@ tests/cases/compiler/arrowFunctionErrorSpan.ts(36,7): error TS2345: Argument of
tests/cases/compiler/arrowFunctionErrorSpan.ts(43,5): error TS2345: Argument of type '() => void' is not assignable to parameter of type '() => number'.
Type 'void' is not assignable to type 'number'.
tests/cases/compiler/arrowFunctionErrorSpan.ts(52,3): error TS2345: Argument of type '(_: any) => number' is not assignable to parameter of type '() => number'.
Target signature provides too few arguments. Expected 1 or more, but got 0.


==== tests/cases/compiler/arrowFunctionErrorSpan.ts (11 errors) ====
Expand Down Expand Up @@ -64,6 +66,7 @@ tests/cases/compiler/arrowFunctionErrorSpan.ts(52,3): error TS2345: Argument of
d) => { });
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(a: any, b: any, c: any, d: any) => void' is not assignable to parameter of type '() => number'.
!!! error TS2345: Target signature provides too few arguments. Expected 4 or more, but got 0.

// single line with a comment
f(/*
Expand Down Expand Up @@ -108,4 +111,5 @@ tests/cases/compiler/arrowFunctionErrorSpan.ts(52,3): error TS2345: Argument of
2);
~~~~~
!!! error TS2345: Argument of type '(_: any) => number' is not assignable to parameter of type '() => number'.
!!! error TS2345: Target signature provides too few arguments. Expected 1 or more, but got 0.

Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(16,5): error TS2322: Type '(x: number) => number' is not assignable to type '() => number'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(19,5): error TS2322: Type '(x: number) => number' is not assignable to type '() => number'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(20,5): error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '() => number'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(22,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '() => number'.
Target signature provides too few arguments. Expected 2 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(33,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x?: number) => number'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(39,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(45,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'.
Target signature provides too few arguments. Expected 2 or more, but got 1.


==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts (7 errors) ====
Expand All @@ -26,18 +33,22 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a = (x: number) => 1; // error, too many required params
~
!!! error TS2322: Type '(x: number) => number' is not assignable to type '() => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
a = b.a; // ok
a = b.a2; // ok
a = b.a3; // error
~
!!! error TS2322: Type '(x: number) => number' is not assignable to type '() => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
a = b.a4; // error
~
!!! error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '() => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
a = b.a5; // ok
a = b.a6; // error
~
!!! error TS2322: Type '(x: number, y: number) => number' is not assignable to type '() => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 0.

var a2: (x?: number) => number;
a2 = () => 1; // ok, same number of required params
Expand All @@ -51,6 +62,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a2 = b.a6; // error
~~
!!! error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x?: number) => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.

var a3: (x: number) => number;
a3 = () => 1; // ok, fewer required params
Expand All @@ -59,6 +71,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a3 = (x: number, y: number) => 1; // error, too many required params
~~
!!! error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.
a3 = b.a; // ok
a3 = b.a2; // ok
a3 = b.a3; // ok
Expand All @@ -67,6 +80,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a3 = b.a6; // error
~~
!!! error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.

var a4: (x: number, y?: number) => number;
a4 = () => 1; // ok, fewer required params
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts(16,5): error TS2322: Type 'new (x: number) => number' is not assignable to type 'new () => number'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts(17,5): error TS2322: Type 'new (x: number, y?: number) => number' is not assignable to type 'new () => number'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts(19,5): error TS2322: Type 'new (x: number, y: number) => number' is not assignable to type 'new () => number'.
Target signature provides too few arguments. Expected 2 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts(27,5): error TS2322: Type 'new (x: number, y: number) => number' is not assignable to type 'new (x?: number) => number'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts(35,5): error TS2322: Type 'new (x: number, y: number) => number' is not assignable to type 'new (x: number) => number'.
Target signature provides too few arguments. Expected 2 or more, but got 1.


==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts (5 errors) ====
Expand All @@ -24,13 +29,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a = b.a3; // error
~
!!! error TS2322: Type 'new (x: number) => number' is not assignable to type 'new () => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
a = b.a4; // error
~
!!! error TS2322: Type 'new (x: number, y?: number) => number' is not assignable to type 'new () => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
a = b.a5; // ok
a = b.a6; // error
~
!!! error TS2322: Type 'new (x: number, y: number) => number' is not assignable to type 'new () => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 0.

var a2: new (x?: number) => number;
a2 = b.a; // ok
Expand All @@ -41,6 +49,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a2 = b.a6; // error
~~
!!! error TS2322: Type 'new (x: number, y: number) => number' is not assignable to type 'new (x?: number) => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.

var a3: new (x: number) => number;
a3 = b.a; // ok
Expand All @@ -51,6 +60,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
a3 = b.a6; // error
~~
!!! error TS2322: Type 'new (x: number, y: number) => number' is not assignable to type 'new (x: number) => number'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.

var a4: new (x: number, y?: number) => number;
a4 = b.a; // ok
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(14,13): error TS2322: Type '(x: T) => any' is not assignable to type '() => T'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(23,13): error TS2322: Type '(x: T, y: T) => any' is not assignable to type '(x: T) => T'.
Target signature provides too few arguments. Expected 2 or more, but got 1.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(63,9): error TS2322: Type '() => T' is not assignable to type '<T>() => T'.
Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(64,9): error TS2322: Type '(x?: T) => T' is not assignable to type '<T>() => T'.
Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(65,9): error TS2322: Type '(x: T) => T' is not assignable to type '<T>() => T'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(66,9): error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '<T>() => T'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(67,9): error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>() => T'.
Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
Expand Down Expand Up @@ -88,7 +92,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(107,13): error TS2322: Type '<T>(x: T) => any' is not assignable to type '<T>() => T'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts(116,13): error TS2322: Type '<T>(x: T, y: T) => any' is not assignable to type '<T>(x: T) => T'.
Target signature provides too few arguments. Expected 2 or more, but got 1.


==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts (29 errors) ====
Expand All @@ -108,6 +114,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
this.a = (x: T) => null; // error, too many required params
~~~~~~
!!! error TS2322: Type '(x: T) => any' is not assignable to type '() => T'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.

this.a2 = () => null; // ok, same T of required params
this.a2 = (x?: T) => null; // ok, same T of required params
Expand All @@ -119,6 +126,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
this.a3 = (x: T, y: T) => null; // error, too many required params
~~~~~~~
!!! error TS2322: Type '(x: T, y: T) => any' is not assignable to type '(x: T) => T'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.

this.a4 = () => null; // ok, fewer required params
this.a4 = (x?: T, y?: T) => null; // ok, fewer required params
Expand Down Expand Up @@ -173,9 +181,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
b.a = t.a3;
~~~
!!! error TS2322: Type '(x: T) => T' is not assignable to type '<T>() => T'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
b.a = t.a4;
~~~
!!! error TS2322: Type '(x: T, y?: T) => T' is not assignable to type '<T>() => T'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.
b.a = t.a5;
~~~
!!! error TS2322: Type '(x?: T, y?: T) => T' is not assignable to type '<T>() => T'.
Expand Down Expand Up @@ -340,6 +350,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
this.a = <T>(x: T) => null; // error, too many required params
~~~~~~
!!! error TS2322: Type '<T>(x: T) => any' is not assignable to type '<T>() => T'.
!!! error TS2322: Target signature provides too few arguments. Expected 1 or more, but got 0.

this.a2 = <T>() => null; // ok, same T of required params
this.a2 = <T>(x?: T) => null; // ok, same T of required params
Expand All @@ -351,6 +362,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
this.a3 = <T>(x: T, y: T) => null; // error, too many required params
~~~~~~~
!!! error TS2322: Type '<T>(x: T, y: T) => any' is not assignable to type '<T>(x: T) => T'.
!!! error TS2322: Target signature provides too few arguments. Expected 2 or more, but got 1.

this.a4 = <T>() => null; // ok, fewer required params
this.a4 = <T>(x?: T, y?: T) => null; // ok, fewer required params
Expand Down
Loading