More explicit error message for function signature length mismatches (#51457)

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
Kevin Gibbons
2023-03-21 09:09:22 -07:00
committed by GitHub
parent f218a562bf
commit de31ebecea
53 changed files with 459 additions and 1 deletions

View File

@@ -19812,6 +19812,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;
}

View File

@@ -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",