Skip to content

Commit c8c6503

Browse files
author
Andy Hanson
committed
WIP MORE
1 parent bfa01a1 commit c8c6503

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10322,7 +10322,7 @@ namespace ts {
1032210322
}
1032310323

1032410324
function hasCorrectArity(node: CallLikeExpression, args: Expression[], signature: Signature) {
10325-
let adjustedArgCount: number; // Apparent number of arguments we will have in this call
10325+
let argCount: number; // Apparent number of arguments we will have in this call
1032610326
let typeArguments: NodeArray<TypeNode>; // Type arguments (undefined if none)
1032710327
let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments
1032810328
let isDecorator: boolean;
@@ -10333,7 +10333,7 @@ namespace ts {
1033310333

1033410334
// Even if the call is incomplete, we'll have a missing expression as our last argument,
1033510335
// so we can say the count is just the arg list length
10336-
adjustedArgCount = args.length;
10336+
argCount = args.length;
1033710337
typeArguments = undefined;
1033810338

1033910339
if (tagExpression.template.kind === SyntaxKind.TemplateExpression) {
@@ -10356,7 +10356,7 @@ namespace ts {
1035610356
else if (node.kind === SyntaxKind.Decorator) {
1035710357
isDecorator = true;
1035810358
typeArguments = undefined;
10359-
adjustedArgCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
10359+
argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
1036010360
}
1036110361
else {
1036210362
const callExpression = <CallExpression>node;
@@ -10367,8 +10367,7 @@ namespace ts {
1036710367
return signature.minArgumentCount === 0;
1036810368
}
1036910369

10370-
//For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument.
10371-
adjustedArgCount = args.length; //callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length;
10370+
argCount = args.length;
1037210371

1037310372
// If we are missing the close paren, the call is incomplete.
1037410373
callIsIncomplete = (<CallExpression>callExpression).arguments.end === callExpression.end;
@@ -10392,12 +10391,12 @@ namespace ts {
1039210391
}
1039310392

1039410393
// Too many arguments implies incorrect arity.
10395-
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
10394+
if (!signature.hasRestParameter && argCount > signature.parameters.length) {
1039610395
return false;
1039710396
}
1039810397

1039910398
// If the call is incomplete, we should skip the lower bound check.
10400-
const hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount;
10399+
const hasEnoughArguments = argCount >= signature.minArgumentCount;
1040110400
return callIsIncomplete || hasEnoughArguments;
1040210401
}
1040310402

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////function str(n: number): string;
4+
/////**
5+
//// * Stringifies a number with radix
6+
//// * @param radix The radix
7+
//// */
8+
////function str(n: number, radix: number): string;
9+
////function str(n: number, radix?: number): string { return ""; }
10+
11+
edit.insert("str(1,");
12+
verify.currentParameterHelpArgumentNameIs("radix");
13+
verify.currentParameterHelpArgumentDocCommentIs("The radix");
14+
verify.currentSignatureHelpIs("str(n: number, radix: number): string");
15+
verify.currentSignatureHelpDocCommentIs("Stringifies a number with radix");

0 commit comments

Comments
 (0)