From b3d521a0bb47aa0918c71fbba9f9244262072de9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 13 Apr 2021 08:25:30 -0700 Subject: [PATCH 1/8] Scribbles + tests The second test actually requires node types --- src/compiler/checker.ts | 44 ++++++++---- .../functionCalls/callWithSpread4.ts | 68 +++++++++++++++++++ 2 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 530e734a552a2..751ffac413ceb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28441,7 +28441,8 @@ namespace ts { for (const sig of signatures) { const minCount = getMinArgumentCount(sig); const maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) belowArgCount = minCount; + // TODO: Not sure why the opposite end of each comparison is here (eg minCount < argCount) + if (belowArgCount < minCount && minCount < argCount) belowArgCount = minCount; if (argCount < maxCount && maxCount < aboveArgCount) aboveArgCount = maxCount; if (minCount < min) { min = minCount; @@ -28455,9 +28456,9 @@ namespace ts { } const hasRestParameter = some(signatures, hasEffectiveRestParameter); - const paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; + const paramRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; if (argCount <= max && hasSpreadArgument) { argCount--; @@ -28466,15 +28467,34 @@ namespace ts { let spanArray: NodeArray; let related: DiagnosticWithLocation | undefined; - const error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - Diagnostics.Expected_at_least_0_arguments_but_got_1 : - Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? + let error; + if (hasRestParameter || hasSpreadArgument) { + if (hasRestParameter && hasSpreadArgument) { + // TODO: Also need to skip tuple rests but w/e + const indexOfRest = Math.max(...signatures.filter(s => signatureHasRestParameter(s)).map(s => s.parameters.length - 1)) + const indexOfSpread = getSpreadArgumentIndex(args) + if (indexOfRest < indexOfSpread) + error = Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more; + else + // "The spread argument {0} is only assignable to a rest parameter." + // " related: This spread was applied to the parameter {0}. (where 0=sig.parameters[indexOfSpread]) + // TODO: also need to move error span to call.arguments[indexOfSpread] + // OR + // Expected 4 arguments but Typescript was not able to match a spread of T[] to the parameter X and following + error = Diagnostics.Something_else; + } + else if (hasRestParameter) { + error = Diagnostics.Expected_at_least_0_arguments_but_got_1; + } else { + // Expected 4 arguments but Typescript could only prove that you provided 2. + error = Diagnostics.Expected_0_arguments_but_got_1_or_more; + } + } + else { + error = (paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - Diagnostics.Expected_0_arguments_but_got_1; + Diagnostics.Expected_0_arguments_but_got_1); + } if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { const paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts new file mode 100644 index 0000000000000..587010ca05c00 --- /dev/null +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts @@ -0,0 +1,68 @@ +// @strict: true +type R = { a: number } +type W = { b: number } +type RW = { a: number, b: number } +declare const pli: { + // (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; + // (streams: ReadonlyArray): Promise; + // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better + (s1: R, s2: RW | W, ...streams: Array): Promise; +} + +declare var writes: W +declare var reads: R +declare var tr: W +declare var gun: RW[] +declare var gz: RW[] +declare var fun: (inp: any) => AsyncGenerator +pli( + reads, + ...gun, + tr, + fun, + ...gz, + writes +); + +declare var anys: any[] +test(...anys) +jsonTransform(...anys) + +pli(...[reads, writes, writes] as const) + + +import fs = require("fs"); +import stream = require("stream"); +import util = require("util"); +import zlib = require("zlib"); + +declare function split(matcher: RegExp, mapper: (line: string) => any): stream.Transform; + +declare function test(x: any, y: () => string): string | undefined; +declare function jsonTransform(t: typeof test): stream.Transform; +declare function disp(x: any): string; + +declare const input: string; +declare const output: string; + +const pipeline = util.promisify(stream.pipeline); + +async function processFile(fastMode: boolean) { + await pipeline( + fs.createReadStream(input), + ...(/\.gz$/.test(input) ? [zlib.createGunzip()] + : /\.br$/.test(input) ? [zlib.createBrotliDecompress()] + : []) as [(zlib.Gunzip | zlib.BrotliDecompress)], + fastMode + ? split(/,?\r?\n/, x => x.length > 1 ? test(JSON.parse(x), () => x) : undefined) + : jsonTransform(test), + async function* (inp: any) { + for await (const x of inp) yield disp(x); + yield "\n]\n"; + }, + ...(/\.gz$/.test(output) ? [zlib.createGzip()] + : /\.br$/.test(output) ? [zlib.createBrotliCompress()] + : []) as [(zlib.Gzip | zlib.BrotliCompress)], + fs.createWriteStream(output) + ); +} From 90e59ab0c32769f04096985f6f76e930790ebbf7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 27 Apr 2021 09:28:22 -0700 Subject: [PATCH 2/8] Basically working The two simple fixes, in arity error reporting, are in, and the simplification of arity error reporting is half-done. I haven't started on any improvements to call assignability. --- src/compiler/checker.ts | 106 +++++++--------- src/compiler/diagnosticMessages.json | 6 +- .../reference/callOverload.errors.txt | 4 +- .../reference/callWithSpread2.errors.txt | 20 +-- .../reference/callWithSpread3.errors.txt | 22 ++-- .../reference/callWithSpread4.errors.txt | 48 +++++++ tests/baselines/reference/callWithSpread4.js | 44 +++++++ .../reference/callWithSpread4.symbols | 117 ++++++++++++++++++ .../baselines/reference/callWithSpread4.types | 103 +++++++++++++++ .../functionParameterArityMismatch.errors.txt | 6 +- .../reference/iteratorSpreadInCall.errors.txt | 4 +- .../iteratorSpreadInCall10.errors.txt | 4 +- .../iteratorSpreadInCall2.errors.txt | 4 +- .../iteratorSpreadInCall4.errors.txt | 4 +- .../noImplicitAnyLoopCrash.errors.txt | 4 +- .../readonlyRestParameters.errors.txt | 4 +- 16 files changed, 396 insertions(+), 104 deletions(-) create mode 100644 tests/baselines/reference/callWithSpread4.errors.txt create mode 100644 tests/baselines/reference/callWithSpread4.js create mode 100644 tests/baselines/reference/callWithSpread4.symbols create mode 100644 tests/baselines/reference/callWithSpread4.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 44a878334edab..5f65ed5b0f15d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28542,6 +28542,9 @@ namespace ts { } } + // function getDiagnosticForExcessParameters() { + // } + function isPromiseResolveArityError(node: CallLikeExpression) { if (!isCallExpression(node) || !isIdentifier(node.expression)) return false; @@ -28559,71 +28562,52 @@ namespace ts { } function getArgumentArityError(node: CallLikeExpression, signatures: readonly Signature[], args: readonly Expression[]) { - let min = Number.POSITIVE_INFINITY; - let max = Number.NEGATIVE_INFINITY; - let belowArgCount = Number.NEGATIVE_INFINITY; - let aboveArgCount = Number.POSITIVE_INFINITY; + let min = Number.POSITIVE_INFINITY; // smallest parameter count + let max = Number.NEGATIVE_INFINITY; // larger parameter count + let maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + let minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments let argCount = args.length; let closestSignature: Signature | undefined; for (const sig of signatures) { - const minCount = getMinArgumentCount(sig); - const maxCount = getParameterCount(sig); - // TODO: Not sure why the opposite end of each comparison is here (eg minCount < argCount) - if (belowArgCount < minCount && minCount < argCount) belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + const minParameter = getMinArgumentCount(sig); + const maxParameter = getParameterCount(sig); + // 1a. find the shortest param count (and call that the closest sig) + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + // 1b. find the longest param count + max = Math.max(max, maxParameter); + // 2a/b. find the shortest param count *longer than the call* + if (minParameter < argCount && minParameter > maxBelow) maxBelow = minParameter; + // find the longest param count *shorter than the call* + if (argCount < maxParameter && maxParameter < minAbove) minAbove = maxParameter; } if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); + return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, maxBelow, minAbove); } const hasRestParameter = some(signatures, hasEffectiveRestParameter); const paramRange = hasRestParameter ? min : min < max ? min + "-" + max : min; + // TODO: save the index too + // TODO: For at least some uses, need to skip spreads of tuples (or should, at least) const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; + // TODO: This is probably a mistake, so remove it later if (argCount <= max && hasSpreadArgument) { argCount--; } - - let spanArray: NodeArray; + const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_after_1_found_a_non_tuple_spread_that_must_be_passed_to_a_rest_parameter + : hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_after_1_found_a_non_tuple_spread_that_must_be_passed_to_a_rest_parameter + : hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 + : paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : Diagnostics.Expected_0_arguments_but_got_1; + // TODO: min === getMinArgumentCount(closestSignature); don't need to call it again + // TODO: This is the only region where the argCount-- shenanigans above could make a difference let related: DiagnosticWithLocation | undefined; - - let error; - if (hasRestParameter || hasSpreadArgument) { - if (hasRestParameter && hasSpreadArgument) { - // TODO: Also need to skip tuple rests but w/e - const indexOfRest = Math.max(...signatures.filter(s => signatureHasRestParameter(s)).map(s => s.parameters.length - 1)) - const indexOfSpread = getSpreadArgumentIndex(args) - if (indexOfRest < indexOfSpread) - error = Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more; - else - // "The spread argument {0} is only assignable to a rest parameter." - // " related: This spread was applied to the parameter {0}. (where 0=sig.parameters[indexOfSpread]) - // TODO: also need to move error span to call.arguments[indexOfSpread] - // OR - // Expected 4 arguments but Typescript was not able to match a spread of T[] to the parameter X and following - error = Diagnostics.Something_else; - } - else if (hasRestParameter) { - error = Diagnostics.Expected_at_least_0_arguments_but_got_1; - } else { - // Expected 4 arguments but Typescript could only prove that you provided 2. - error = Diagnostics.Expected_0_arguments_but_got_1_or_more; - } - } - else { - error = (paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - Diagnostics.Expected_0_arguments_but_got_1); - } - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { const paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { @@ -28636,30 +28620,26 @@ namespace ts { } } - if (!hasSpreadArgument && argCount < min) { + if (!hasSpreadArgument && argCount < min) { // no spread and not enough args -- too short: put the error span on the call expression, not any of the args const diagnostic = getDiagnosticForCallNode(node, error, paramRange, argCount); return related ? addRelatedInfo(diagnostic, related) : diagnostic; } - - if (hasRestParameter || hasSpreadArgument) { - spanArray = factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - const nextArg = elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); - } - } - else { - spanArray = factory.createNodeArray(args.slice(max)); - } - - const pos = first(spanArray).pos; - let end = last(spanArray).end; + // excess parameters or a spread + // error goes right [after] spread, or on the excess parameters, whichever comes first + // TODO: refactor all this part into new function getDiagnosticForExcessParameters + const errorStart = hasSpreadArgument + ? Math.min(max, args.length - 1, getSpreadArgumentIndex(args)) + : max; + Debug.assert(!hasRestParameter && !hasSpreadArgument || hasSpreadArgument, "lol 1") + Debug.assert(argCount !== max && (argCount > max && argCount === args.length || argCount < max && argCount === args.length - 1), "oh no 2") + const errorSpan = factory.createNodeArray(args.slice(errorStart)); + const pos = first(errorSpan).pos; + let end = last(errorSpan).end; if (end === pos) { end++; } - setTextRangePosEnd(spanArray, pos, end); - const diagnostic = createDiagnosticForNodeArray( - getSourceFileOfNode(node), spanArray, error, paramRange, argCount); + setTextRangePosEnd(errorSpan, pos, end); + const diagnostic = createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan, error, paramRange, hasSpreadArgument ? getSpreadArgumentIndex(args) : argCount); return related ? addRelatedInfo(diagnostic, related) : diagnostic; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8828ae051c56b..0904fbdfa5da0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -526,7 +526,7 @@ "'extends' clause already seen.": { "category": "Error", "code": 1172 - }, + }, "'extends' clause must precede 'implements' clause.": { "category": "Error", "code": 1173 @@ -2386,11 +2386,11 @@ "category": "Error", "code": 2555 }, - "Expected {0} arguments, but got {1} or more.": { + "Expected {0} arguments, but after {1}, found a non-tuple spread that must be passed to a rest parameter.": { "category": "Error", "code": 2556 }, - "Expected at least {0} arguments, but got {1} or more.": { + "Expected at least {0} arguments, but after {1}, found a non-tuple spread that must be passed to a rest parameter.": { "category": "Error", "code": 2557 }, diff --git a/tests/baselines/reference/callOverload.errors.txt b/tests/baselines/reference/callOverload.errors.txt index 0f6a2ade085a0..b0c1229a2bba2 100644 --- a/tests/baselines/reference/callOverload.errors.txt +++ b/tests/baselines/reference/callOverload.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(7,7): error TS2554: Expected 1 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(8,15): error TS2554: Expected 2 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(10,1): error TS2555: Expected at least 1 arguments, but got 0. -tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2557: Expected at least 1 arguments, but got 0 or more. +tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callOverload.ts (4 errors) ==== @@ -24,5 +24,5 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. withRest(...n); ~~~~ -!!! error TS2557: Expected at least 1 arguments, but got 0 or more. +!!! error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread2.errors.txt b/tests/baselines/reference/callWithSpread2.errors.txt index 080c229e6042e..5cf9dfe2ce9d6 100644 --- a/tests/baselines/reference/callWithSpread2.errors.txt +++ b/tests/baselines/reference/callWithSpread2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: Expected 1 arguments, but got 2 or more. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: Expected 0 arguments, but got 1 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: Expected 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(27,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(28,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -9,10 +9,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,13): err tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: Expected 1-3 arguments, but got 0 or more. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: Expected 1-3 arguments, but got 0 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,8): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: Expected 2-4 arguments, but got 1 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: Expected 2-4 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (12 errors) ==== @@ -40,10 +40,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err // extra arguments normal("g", ...ns) ~~~~~ -!!! error TS2556: Expected 1 arguments, but got 2 or more. +!!! error TS2556: Expected 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. thunk(...ns) ~~~~~ -!!! error TS2556: Expected 0 arguments, but got 1 or more. +!!! error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. // bad all(...mixed) @@ -69,17 +69,17 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. prefix(...ns) // required parameters are required ~~~~~ -!!! error TS2556: Expected 1-3 arguments, but got 0 or more. +!!! error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts:3:25: An argument for 's' was not provided. prefix(...mixed) ~~~~~~~~ -!!! error TS2556: Expected 1-3 arguments, but got 0 or more. +!!! error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts:3:25: An argument for 's' was not provided. prefix(...tuple) ~~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. prefix2("g", ...ns); ~~~~~ -!!! error TS2556: Expected 2-4 arguments, but got 1 or more. +!!! error TS2556: Expected 2-4 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts:7:37: An argument for 'n' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread3.errors.txt b/tests/baselines/reference/callWithSpread3.errors.txt index 062c273a26a9c..0f2b7482138a5 100644 --- a/tests/baselines/reference/callWithSpread3.errors.txt +++ b/tests/baselines/reference/callWithSpread3.errors.txt @@ -4,12 +4,12 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(16,15): err tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(17,15): error TS2554: Expected 2 arguments, but got 6. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(18,12): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(19,5): error TS2554: Expected 2 arguments, but got 3. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2557: Expected at least 2 arguments, but got 0 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(21,6): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,13): error TS2557: Expected at least 2 arguments, but got 1 or more. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,13): error TS2557: Expected at least 2 arguments, but got 2 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(25,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,13): error TS2557: Expected at least 2 arguments, but got 4 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts (12 errors) ==== @@ -46,18 +46,18 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,13): err !!! error TS2554: Expected 2 arguments, but got 3. fs2_(...s_); // error on ...s_ ~~~~~ -!!! error TS2557: Expected at least 2 arguments, but got 0 or more. +!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts:9:23: An argument for 'a' was not provided. fs2_(...s2n_); // error on ...s2n_ ~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. fs2_(...s_, ...s_); // error FIXME: bad error message - ~~~~~ -!!! error TS2557: Expected at least 2 arguments, but got 1 or more. + ~~~~~~~~~~~~ +!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts:9:34: An argument for 'b' was not provided. fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message - ~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but got 2 or more. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_(...s2_); // error on ...s2_ ~~~~~~ @@ -68,8 +68,8 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,13): err fs2_(...s2_, ...s_); fs2_(...s2_, ...s2_); fs2_(...s_, ...s2_); - ~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but got 4 or more. + ~~~~~~~~~~~~~ +!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. fs2n_(...s2n_); fs2n_(...s2); // fs2n_(...s2, ...n_); // FIXME: should compile diff --git a/tests/baselines/reference/callWithSpread4.errors.txt b/tests/baselines/reference/callWithSpread4.errors.txt new file mode 100644 index 0000000000000..c5bc104b55801 --- /dev/null +++ b/tests/baselines/reference/callWithSpread4.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(16,32): error TS2583: Cannot find name 'AsyncGenerator'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2018' or later. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(19,5): error TS2557: Expected at least 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(28,6): error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. + + +==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (3 errors) ==== + type R = { a: number } + type W = { b: number } + type RW = { a: number, b: number } + declare const pli: { + (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; + (streams: ReadonlyArray): Promise; + // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better + (s1: R, s2: RW | W, ...streams: Array): Promise; + } + + declare var writes: W + declare var reads: R + declare var tr: W + declare var gun: RW[] + declare var gz: RW[] + declare var fun: (inp: any) => AsyncGenerator + ~~~~~~~~~~~~~~ +!!! error TS2583: Cannot find name 'AsyncGenerator'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2018' or later. + pli( + reads, + ...gun, + ~~~~~~~ + tr, + ~~~~~~~ + fun, + ~~~~~~~~ + ...gz, + ~~~~~~~~~~ + writes + ~~~~~~~~~~ +!!! error TS2557: Expected at least 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. + ); + + declare function test(x: any, y: () => string): string | undefined; + declare var anys: any[] + test(...anys) + ~~~~~~~ +!!! error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts:26:23: An argument for 'x' was not provided. + + pli(...[reads, writes, writes] as const) + \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread4.js b/tests/baselines/reference/callWithSpread4.js new file mode 100644 index 0000000000000..215147ebadb0c --- /dev/null +++ b/tests/baselines/reference/callWithSpread4.js @@ -0,0 +1,44 @@ +//// [callWithSpread4.ts] +type R = { a: number } +type W = { b: number } +type RW = { a: number, b: number } +declare const pli: { + (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; + (streams: ReadonlyArray): Promise; + // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better + (s1: R, s2: RW | W, ...streams: Array): Promise; +} + +declare var writes: W +declare var reads: R +declare var tr: W +declare var gun: RW[] +declare var gz: RW[] +declare var fun: (inp: any) => AsyncGenerator +pli( + reads, + ...gun, + tr, + fun, + ...gz, + writes +); + +declare function test(x: any, y: () => string): string | undefined; +declare var anys: any[] +test(...anys) + +pli(...[reads, writes, writes] as const) + + +//// [callWithSpread4.js] +"use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) + to[j] = from[i]; + return to; +}; +pli.apply(void 0, __spreadArray(__spreadArray(__spreadArray(__spreadArray([reads], gun), [tr, + fun]), gz), [writes])); +test.apply(void 0, anys); +pli.apply(void 0, [reads, writes, writes]); diff --git a/tests/baselines/reference/callWithSpread4.symbols b/tests/baselines/reference/callWithSpread4.symbols new file mode 100644 index 0000000000000..3a5016957c378 --- /dev/null +++ b/tests/baselines/reference/callWithSpread4.symbols @@ -0,0 +1,117 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts === +type R = { a: number } +>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) +>a : Symbol(a, Decl(callWithSpread4.ts, 0, 10)) + +type W = { b: number } +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) +>b : Symbol(b, Decl(callWithSpread4.ts, 1, 10)) + +type RW = { a: number, b: number } +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>a : Symbol(a, Decl(callWithSpread4.ts, 2, 11)) +>b : Symbol(b, Decl(callWithSpread4.ts, 2, 22)) + +declare const pli: { +>pli : Symbol(pli, Decl(callWithSpread4.ts, 3, 13)) + + (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; +>s1 : Symbol(s1, Decl(callWithSpread4.ts, 4, 5)) +>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) +>s2 : Symbol(s2, Decl(callWithSpread4.ts, 4, 11)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>s3 : Symbol(s3, Decl(callWithSpread4.ts, 4, 19)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>s4 : Symbol(s4, Decl(callWithSpread4.ts, 4, 27)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>s5 : Symbol(s5, Decl(callWithSpread4.ts, 4, 35)) +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) + + (streams: ReadonlyArray): Promise; +>streams : Symbol(streams, Decl(callWithSpread4.ts, 5, 5)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --)) +>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) + + // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better + (s1: R, s2: RW | W, ...streams: Array): Promise; +>s1 : Symbol(s1, Decl(callWithSpread4.ts, 7, 5)) +>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) +>s2 : Symbol(s2, Decl(callWithSpread4.ts, 7, 11)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) +>streams : Symbol(streams, Decl(callWithSpread4.ts, 7, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) +} + +declare var writes: W +>writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) + +declare var reads: R +>reads : Symbol(reads, Decl(callWithSpread4.ts, 11, 11)) +>R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) + +declare var tr: W +>tr : Symbol(tr, Decl(callWithSpread4.ts, 12, 11)) +>W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) + +declare var gun: RW[] +>gun : Symbol(gun, Decl(callWithSpread4.ts, 13, 11)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) + +declare var gz: RW[] +>gz : Symbol(gz, Decl(callWithSpread4.ts, 14, 11)) +>RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) + +declare var fun: (inp: any) => AsyncGenerator +>fun : Symbol(fun, Decl(callWithSpread4.ts, 15, 11)) +>inp : Symbol(inp, Decl(callWithSpread4.ts, 15, 18)) + +pli( +>pli : Symbol(pli, Decl(callWithSpread4.ts, 3, 13)) + + reads, +>reads : Symbol(reads, Decl(callWithSpread4.ts, 11, 11)) + + ...gun, +>gun : Symbol(gun, Decl(callWithSpread4.ts, 13, 11)) + + tr, +>tr : Symbol(tr, Decl(callWithSpread4.ts, 12, 11)) + + fun, +>fun : Symbol(fun, Decl(callWithSpread4.ts, 15, 11)) + + ...gz, +>gz : Symbol(gz, Decl(callWithSpread4.ts, 14, 11)) + + writes +>writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) + +); + +declare function test(x: any, y: () => string): string | undefined; +>test : Symbol(test, Decl(callWithSpread4.ts, 23, 2)) +>x : Symbol(x, Decl(callWithSpread4.ts, 25, 22)) +>y : Symbol(y, Decl(callWithSpread4.ts, 25, 29)) + +declare var anys: any[] +>anys : Symbol(anys, Decl(callWithSpread4.ts, 26, 11)) + +test(...anys) +>test : Symbol(test, Decl(callWithSpread4.ts, 23, 2)) +>anys : Symbol(anys, Decl(callWithSpread4.ts, 26, 11)) + +pli(...[reads, writes, writes] as const) +>pli : Symbol(pli, Decl(callWithSpread4.ts, 3, 13)) +>reads : Symbol(reads, Decl(callWithSpread4.ts, 11, 11)) +>writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) +>writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) + diff --git a/tests/baselines/reference/callWithSpread4.types b/tests/baselines/reference/callWithSpread4.types new file mode 100644 index 0000000000000..8ecb32c2c5bbc --- /dev/null +++ b/tests/baselines/reference/callWithSpread4.types @@ -0,0 +1,103 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts === +type R = { a: number } +>R : R +>a : number + +type W = { b: number } +>W : W +>b : number + +type RW = { a: number, b: number } +>RW : RW +>a : number +>b : number + +declare const pli: { +>pli : { (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; (streams: ReadonlyArray): Promise; (s1: R, s2: RW | W, ...streams: Array): Promise; } + + (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; +>s1 : R +>s2 : RW +>s3 : RW +>s4 : RW +>s5 : W + + (streams: ReadonlyArray): Promise; +>streams : readonly (R | W | RW)[] + + // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better + (s1: R, s2: RW | W, ...streams: Array): Promise; +>s1 : R +>s2 : W | RW +>streams : (W | RW)[] +} + +declare var writes: W +>writes : W + +declare var reads: R +>reads : R + +declare var tr: W +>tr : W + +declare var gun: RW[] +>gun : RW[] + +declare var gz: RW[] +>gz : RW[] + +declare var fun: (inp: any) => AsyncGenerator +>fun : (inp: any) => any +>inp : any + +pli( +>pli( reads, ...gun, tr, fun, ...gz, writes) : Promise +>pli : { (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; (streams: readonly (R | W | RW)[]): Promise; (s1: R, s2: W | RW, ...streams: (W | RW)[]): Promise; } + + reads, +>reads : R + + ...gun, +>...gun : RW +>gun : RW[] + + tr, +>tr : W + + fun, +>fun : (inp: any) => any + + ...gz, +>...gz : RW +>gz : RW[] + + writes +>writes : W + +); + +declare function test(x: any, y: () => string): string | undefined; +>test : (x: any, y: () => string) => string | undefined +>x : any +>y : () => string + +declare var anys: any[] +>anys : any[] + +test(...anys) +>test(...anys) : string | undefined +>test : (x: any, y: () => string) => string | undefined +>...anys : any +>anys : any[] + +pli(...[reads, writes, writes] as const) +>pli(...[reads, writes, writes] as const) : Promise +>pli : { (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; (streams: readonly (R | W | RW)[]): Promise; (s1: R, s2: W | RW, ...streams: (W | RW)[]): Promise; } +>...[reads, writes, writes] as const : R | W +>[reads, writes, writes] as const : readonly [R, W, W] +>[reads, writes, writes] : readonly [R, W, W] +>reads : R +>writes : W +>writes : W + diff --git a/tests/baselines/reference/functionParameterArityMismatch.errors.txt b/tests/baselines/reference/functionParameterArityMismatch.errors.txt index 1182ecb58ab15..8cdbd37c4ab06 100644 --- a/tests/baselines/reference/functionParameterArityMismatch.errors.txt +++ b/tests/baselines/reference/functionParameterArityMismatch.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/functionParameterArityMismatch.ts(11,1): error TS2575: No o tests/cases/compiler/functionParameterArityMismatch.ts(12,1): error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(13,1): error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(14,22): error TS2554: Expected 0-6 arguments, but got 7. -tests/cases/compiler/functionParameterArityMismatch.ts(15,12): error TS2556: Expected 0-6 arguments, but got 5 or more. +tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: Expected 0-6 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/compiler/functionParameterArityMismatch.ts (8 errors) ==== @@ -39,6 +39,6 @@ tests/cases/compiler/functionParameterArityMismatch.ts(15,12): error TS2556: Exp ~ !!! error TS2554: Expected 0-6 arguments, but got 7. f2(...[1], 2, 3, 4, 5, 6); - ~~~~~~~~~~~~~ -!!! error TS2556: Expected 0-6 arguments, but got 5 or more. + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2556: Expected 0-6 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index ca985c71f98e1..90d8dd0dd2841 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: Expected 1 arguments, but got 0 or more. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== @@ -18,5 +18,5 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but got 0 or more. +!!! error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts:1:14: An argument for 's' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index ddbb574e076eb..1c92cbc84598b 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: Expected 1 arguments, but got 0 or more. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== @@ -18,5 +18,5 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556 foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but got 0 or more. +!!! error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts:1:17: An argument for 's' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index 9074b531f6357..2f6dc257798eb 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: Expected 1 arguments, but got 0 or more. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== @@ -18,5 +18,5 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but got 0 or more. +!!! error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts:1:14: An argument for 's' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index b68f7e2182683..5b8242522227c 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: Expected at least 1 arguments, but got 0 or more. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== @@ -18,5 +18,5 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 1 arguments, but got 0 or more. +!!! error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts:1:14: An argument for 's1' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt index 7526354a4c5e4..2e73e1a894a17 100644 --- a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt +++ b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: Expected 0 arguments, but got 1 or more. +tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number' is not an array type. @@ -8,7 +8,7 @@ tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number while (1) { bar = ~foo(...bar); ~~~~~~ -!!! error TS2556: Expected 0 arguments, but got 1 or more. +!!! error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. ~~~ !!! error TS2461: Type 'number' is not an array type. } diff --git a/tests/baselines/reference/readonlyRestParameters.errors.txt b/tests/baselines/reference/readonlyRestParameters.errors.txt index e2f486248d7a3..dc3a16fc90c02 100644 --- a/tests/baselines/reference/readonlyRestParameters.errors.txt +++ b/tests/baselines/reference/readonlyRestParameters.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: Expected 2 arguments, but got 0 or more. +tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,15): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): error TS2542: Index signature in type 'readonly string[]' only permits reading. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): erro function f1(...args: readonly string[]) { f0(...args); // Error ~~~~~~~ -!!! error TS2556: Expected 2 arguments, but got 0 or more. +!!! error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. !!! related TS6210 tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts:1:13: An argument for 'a' was not provided. f1('abc', 'def'); f1('abc', ...args); From 764416157c4b7eead717e4555355edd58702f135 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 27 Apr 2021 09:29:40 -0700 Subject: [PATCH 3/8] trim out too-real test case --- .../functionCalls/callWithSpread4.ts | 44 ++----------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts index 587010ca05c00..955d5228d704a 100644 --- a/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts @@ -3,9 +3,8 @@ type R = { a: number } type W = { b: number } type RW = { a: number, b: number } declare const pli: { - // (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; - // (streams: ReadonlyArray): Promise; - // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better + (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; + (streams: ReadonlyArray): Promise; (s1: R, s2: RW | W, ...streams: Array): Promise; } @@ -24,45 +23,8 @@ pli( writes ); +declare function test(x: any, y: () => string): string | undefined; declare var anys: any[] test(...anys) -jsonTransform(...anys) pli(...[reads, writes, writes] as const) - - -import fs = require("fs"); -import stream = require("stream"); -import util = require("util"); -import zlib = require("zlib"); - -declare function split(matcher: RegExp, mapper: (line: string) => any): stream.Transform; - -declare function test(x: any, y: () => string): string | undefined; -declare function jsonTransform(t: typeof test): stream.Transform; -declare function disp(x: any): string; - -declare const input: string; -declare const output: string; - -const pipeline = util.promisify(stream.pipeline); - -async function processFile(fastMode: boolean) { - await pipeline( - fs.createReadStream(input), - ...(/\.gz$/.test(input) ? [zlib.createGunzip()] - : /\.br$/.test(input) ? [zlib.createBrotliDecompress()] - : []) as [(zlib.Gunzip | zlib.BrotliDecompress)], - fastMode - ? split(/,?\r?\n/, x => x.length > 1 ? test(JSON.parse(x), () => x) : undefined) - : jsonTransform(test), - async function* (inp: any) { - for await (const x of inp) yield disp(x); - yield "\n]\n"; - }, - ...(/\.gz$/.test(output) ? [zlib.createGzip()] - : /\.br$/.test(output) ? [zlib.createBrotliCompress()] - : []) as [(zlib.Gzip | zlib.BrotliCompress)], - fs.createWriteStream(output) - ); -} From 42158f6fc56cb163afe173c90b672bd923e290b5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 27 Apr 2021 16:15:50 -0700 Subject: [PATCH 4/8] Finish cleanup And reword error a little. --- src/compiler/checker.ts | 99 ++++++++----------- src/compiler/diagnosticMessages.json | 4 +- .../reference/callOverload.errors.txt | 5 +- .../reference/callWithSpread2.errors.txt | 23 ++--- .../reference/callWithSpread3.errors.txt | 18 ++-- .../reference/callWithSpread4.errors.txt | 15 +-- tests/baselines/reference/callWithSpread4.js | 13 +-- .../reference/callWithSpread4.symbols | 62 ++++++------ .../baselines/reference/callWithSpread4.types | 5 +- .../functionParameterArityMismatch.errors.txt | 4 +- .../reference/iteratorSpreadInCall.errors.txt | 5 +- .../iteratorSpreadInCall10.errors.txt | 5 +- .../iteratorSpreadInCall2.errors.txt | 5 +- .../iteratorSpreadInCall4.errors.txt | 5 +- .../noImplicitAnyLoopCrash.errors.txt | 4 +- .../readonlyRestParameters.errors.txt | 5 +- .../functionCalls/callWithSpread4.ts | 1 + 17 files changed, 120 insertions(+), 158 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5f65ed5b0f15d..e6476bab5036d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28542,9 +28542,6 @@ namespace ts { } } - // function getDiagnosticForExcessParameters() { - // } - function isPromiseResolveArityError(node: CallLikeExpression) { if (!isCallExpression(node) || !isIdentifier(node.expression)) return false; @@ -28567,80 +28564,68 @@ namespace ts { let maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments let minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments - let argCount = args.length; let closestSignature: Signature | undefined; for (const sig of signatures) { const minParameter = getMinArgumentCount(sig); const maxParameter = getParameterCount(sig); - // 1a. find the shortest param count (and call that the closest sig) + // shortest/longest parameter counts if (minParameter < min) { min = minParameter; closestSignature = sig; } - // 1b. find the longest param count max = Math.max(max, maxParameter); - // 2a/b. find the shortest param count *longer than the call* - if (minParameter < argCount && minParameter > maxBelow) maxBelow = minParameter; - // find the longest param count *shorter than the call* - if (argCount < maxParameter && maxParameter < minAbove) minAbove = maxParameter; + // shortest parameter count *longer than the call*/longest parametercount *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) minAbove = maxParameter; } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, maxBelow, minAbove); - } const hasRestParameter = some(signatures, hasEffectiveRestParameter); - const paramRange = hasRestParameter ? min + const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; + const parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - // TODO: save the index too - // TODO: For at least some uses, need to skip spreads of tuples (or should, at least) - const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - // TODO: This is probably a mistake, so remove it later - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_after_1_found_a_non_tuple_spread_that_must_be_passed_to_a_rest_parameter - : hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_after_1_found_a_non_tuple_spread_that_must_be_passed_to_a_rest_parameter + const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_after_1_found_a_spread_that_must_be_passed_to_a_rest_parameter + : hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_after_1_found_a_spread_that_must_be_passed_to_a_rest_parameter : hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 - : paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : Diagnostics.Expected_0_arguments_but_got_1; - // TODO: min === getMinArgumentCount(closestSignature); don't need to call it again - // TODO: This is the only region where the argCount-- shenanigans above could make a difference - let related: DiagnosticWithLocation | undefined; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - const paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = createDiagnosticForNode( - paramDecl, - isBindingPattern(paramDecl.name) ? Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - isRestParameter(paramDecl) ? Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : Diagnostics.An_argument_for_0_was_not_provided, - !paramDecl.name ? argCount : !isBindingPattern(paramDecl.name) ? idText(getFirstIdentifier(paramDecl.name)) : undefined + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min && !hasSpreadArgument) { + // too short: put the error span on the call expression, not any of the args + const diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length) + const parameter = closestSignature?.declaration?.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + const parameterError = createDiagnosticForNode( + parameter, + isBindingPattern(parameter.name) ? Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : isRestParameter(parameter) ? Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : Diagnostics.An_argument_for_0_was_not_provided, + !parameter.name ? args.length : !isBindingPattern(parameter.name) ? idText(getFirstIdentifier(parameter.name)) : undefined ); + return addRelatedInfo(diagnostic, parameterError); } + return diagnostic; + } + else { + // too long/spread; error goes on spread or on the excess parameters + const spreadIndex = getSpreadArgumentIndex(args) + const hasSpreadArgument = spreadIndex > -1 + const errorStart = hasSpreadArgument + ? Math.min(max, args.length - 1, spreadIndex) + : max; + const errorSpan = factory.createNodeArray(args.slice(errorStart)); + const pos = first(errorSpan).pos; + let end = last(errorSpan).end; + if (end === pos) { + end++; + } + setTextRangePosEnd(errorSpan, pos, end); + return createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan, error, parameterRange, hasSpreadArgument ? spreadIndex : args.length); } - - if (!hasSpreadArgument && argCount < min) { // no spread and not enough args -- too short: put the error span on the call expression, not any of the args - const diagnostic = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? addRelatedInfo(diagnostic, related) : diagnostic; - } - // excess parameters or a spread - // error goes right [after] spread, or on the excess parameters, whichever comes first - // TODO: refactor all this part into new function getDiagnosticForExcessParameters - const errorStart = hasSpreadArgument - ? Math.min(max, args.length - 1, getSpreadArgumentIndex(args)) - : max; - Debug.assert(!hasRestParameter && !hasSpreadArgument || hasSpreadArgument, "lol 1") - Debug.assert(argCount !== max && (argCount > max && argCount === args.length || argCount < max && argCount === args.length - 1), "oh no 2") - const errorSpan = factory.createNodeArray(args.slice(errorStart)); - const pos = first(errorSpan).pos; - let end = last(errorSpan).end; - if (end === pos) { - end++; - } - setTextRangePosEnd(errorSpan, pos, end); - const diagnostic = createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan, error, paramRange, hasSpreadArgument ? getSpreadArgumentIndex(args) : argCount); - return related ? addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node: Node, signatures: readonly Signature[], typeArguments: NodeArray) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0904fbdfa5da0..9700a6f2cc828 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2386,11 +2386,11 @@ "category": "Error", "code": 2555 }, - "Expected {0} arguments, but after {1}, found a non-tuple spread that must be passed to a rest parameter.": { + "Expected {0} arguments, but after {1}, found a spread that must be passed to a rest parameter.": { "category": "Error", "code": 2556 }, - "Expected at least {0} arguments, but after {1}, found a non-tuple spread that must be passed to a rest parameter.": { + "Expected at least {0} arguments, but after {1}, found a spread that must be passed to a rest parameter.": { "category": "Error", "code": 2557 }, diff --git a/tests/baselines/reference/callOverload.errors.txt b/tests/baselines/reference/callOverload.errors.txt index b0c1229a2bba2..b11d90f2b9ee9 100644 --- a/tests/baselines/reference/callOverload.errors.txt +++ b/tests/baselines/reference/callOverload.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(7,7): error TS2554: Expected 1 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(8,15): error TS2554: Expected 2 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(10,1): error TS2555: Expected at least 1 arguments, but got 0. -tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callOverload.ts (4 errors) ==== @@ -24,5 +24,4 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. withRest(...n); ~~~~ -!!! error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. \ No newline at end of file +!!! error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread2.errors.txt b/tests/baselines/reference/callWithSpread2.errors.txt index 5cf9dfe2ce9d6..51b2877f4a3bb 100644 --- a/tests/baselines/reference/callWithSpread2.errors.txt +++ b/tests/baselines/reference/callWithSpread2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: Expected 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: Expected 1 arguments, but after 1, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(27,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(28,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -9,10 +9,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,13): err tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,8): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: Expected 2-4 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: Expected 2-4 arguments, but after 1, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (12 errors) ==== @@ -40,10 +40,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err // extra arguments normal("g", ...ns) ~~~~~ -!!! error TS2556: Expected 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2556: Expected 1 arguments, but after 1, found a spread that must be passed to a rest parameter. thunk(...ns) ~~~~~ -!!! error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. // bad all(...mixed) @@ -69,17 +69,14 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. prefix(...ns) // required parameters are required ~~~~~ -!!! error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts:3:25: An argument for 's' was not provided. +!!! error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. prefix(...mixed) ~~~~~~~~ -!!! error TS2556: Expected 1-3 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts:3:25: An argument for 's' was not provided. +!!! error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. prefix(...tuple) ~~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. prefix2("g", ...ns); ~~~~~ -!!! error TS2556: Expected 2-4 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts:7:37: An argument for 'n' was not provided. +!!! error TS2556: Expected 2-4 arguments, but after 1, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread3.errors.txt b/tests/baselines/reference/callWithSpread3.errors.txt index 0f2b7482138a5..24a438ed4a856 100644 --- a/tests/baselines/reference/callWithSpread3.errors.txt +++ b/tests/baselines/reference/callWithSpread3.errors.txt @@ -4,12 +4,12 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(16,15): err tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(17,15): error TS2554: Expected 2 arguments, but got 6. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(18,12): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(19,5): error TS2554: Expected 2 arguments, but got 3. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(21,6): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(25,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts (12 errors) ==== @@ -46,18 +46,16 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): erro !!! error TS2554: Expected 2 arguments, but got 3. fs2_(...s_); // error on ...s_ ~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts:9:23: An argument for 'a' was not provided. +!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. fs2_(...s2n_); // error on ...s2n_ ~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. fs2_(...s_, ...s_); // error FIXME: bad error message ~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts:9:34: An argument for 'b' was not provided. +!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message ~~~~~~~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_(...s2_); // error on ...s2_ ~~~~~~ @@ -69,7 +67,7 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): erro fs2_(...s2_, ...s2_); fs2_(...s_, ...s2_); ~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. fs2n_(...s2n_); fs2n_(...s2); // fs2n_(...s2, ...n_); // FIXME: should compile diff --git a/tests/baselines/reference/callWithSpread4.errors.txt b/tests/baselines/reference/callWithSpread4.errors.txt index c5bc104b55801..27cd273ade6fa 100644 --- a/tests/baselines/reference/callWithSpread4.errors.txt +++ b/tests/baselines/reference/callWithSpread4.errors.txt @@ -1,16 +1,14 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(16,32): error TS2583: Cannot find name 'AsyncGenerator'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2018' or later. -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(19,5): error TS2557: Expected at least 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(28,6): error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(18,5): error TS2557: Expected at least 1 arguments, but after 1, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. -==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (3 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (2 errors) ==== type R = { a: number } type W = { b: number } type RW = { a: number, b: number } declare const pli: { (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; (streams: ReadonlyArray): Promise; - // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better (s1: R, s2: RW | W, ...streams: Array): Promise; } @@ -20,8 +18,6 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(28,6): erro declare var gun: RW[] declare var gz: RW[] declare var fun: (inp: any) => AsyncGenerator - ~~~~~~~~~~~~~~ -!!! error TS2583: Cannot find name 'AsyncGenerator'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2018' or later. pli( reads, ...gun, @@ -34,15 +30,14 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(28,6): erro ~~~~~~~~~~ writes ~~~~~~~~~~ -!!! error TS2557: Expected at least 1 arguments, but after 1, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2557: Expected at least 1 arguments, but after 1, found a spread that must be passed to a rest parameter. ); declare function test(x: any, y: () => string): string | undefined; declare var anys: any[] test(...anys) ~~~~~~~ -!!! error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts:26:23: An argument for 'x' was not provided. +!!! error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. pli(...[reads, writes, writes] as const) \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread4.js b/tests/baselines/reference/callWithSpread4.js index 215147ebadb0c..0db1129c0bb11 100644 --- a/tests/baselines/reference/callWithSpread4.js +++ b/tests/baselines/reference/callWithSpread4.js @@ -5,7 +5,6 @@ type RW = { a: number, b: number } declare const pli: { (s1: R, s2: RW, s3: RW, s4: RW, s5: W): Promise; (streams: ReadonlyArray): Promise; - // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better (s1: R, s2: RW | W, ...streams: Array): Promise; } @@ -33,12 +32,6 @@ pli(...[reads, writes, writes] as const) //// [callWithSpread4.js] "use strict"; -var __spreadArray = (this && this.__spreadArray) || function (to, from) { - for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) - to[j] = from[i]; - return to; -}; -pli.apply(void 0, __spreadArray(__spreadArray(__spreadArray(__spreadArray([reads], gun), [tr, - fun]), gz), [writes])); -test.apply(void 0, anys); -pli.apply(void 0, [reads, writes, writes]); +pli(reads, ...gun, tr, fun, ...gz, writes); +test(...anys); +pli(...[reads, writes, writes]); diff --git a/tests/baselines/reference/callWithSpread4.symbols b/tests/baselines/reference/callWithSpread4.symbols index 3a5016957c378..5c3e96596ef60 100644 --- a/tests/baselines/reference/callWithSpread4.symbols +++ b/tests/baselines/reference/callWithSpread4.symbols @@ -26,92 +26,92 @@ declare const pli: { >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) >s5 : Symbol(s5, Decl(callWithSpread4.ts, 4, 35)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) (streams: ReadonlyArray): Promise; >streams : Symbol(streams, Decl(callWithSpread4.ts, 5, 5)) ->ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --)) >R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) ->Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) - // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better (s1: R, s2: RW | W, ...streams: Array): Promise; ->s1 : Symbol(s1, Decl(callWithSpread4.ts, 7, 5)) +>s1 : Symbol(s1, Decl(callWithSpread4.ts, 6, 5)) >R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) ->s2 : Symbol(s2, Decl(callWithSpread4.ts, 7, 11)) +>s2 : Symbol(s2, Decl(callWithSpread4.ts, 6, 11)) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) ->streams : Symbol(streams, Decl(callWithSpread4.ts, 7, 23)) ->Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>streams : Symbol(streams, Decl(callWithSpread4.ts, 6, 23)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) ->Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) } declare var writes: W ->writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) +>writes : Symbol(writes, Decl(callWithSpread4.ts, 9, 11)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) declare var reads: R ->reads : Symbol(reads, Decl(callWithSpread4.ts, 11, 11)) +>reads : Symbol(reads, Decl(callWithSpread4.ts, 10, 11)) >R : Symbol(R, Decl(callWithSpread4.ts, 0, 0)) declare var tr: W ->tr : Symbol(tr, Decl(callWithSpread4.ts, 12, 11)) +>tr : Symbol(tr, Decl(callWithSpread4.ts, 11, 11)) >W : Symbol(W, Decl(callWithSpread4.ts, 0, 22)) declare var gun: RW[] ->gun : Symbol(gun, Decl(callWithSpread4.ts, 13, 11)) +>gun : Symbol(gun, Decl(callWithSpread4.ts, 12, 11)) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) declare var gz: RW[] ->gz : Symbol(gz, Decl(callWithSpread4.ts, 14, 11)) +>gz : Symbol(gz, Decl(callWithSpread4.ts, 13, 11)) >RW : Symbol(RW, Decl(callWithSpread4.ts, 1, 22)) declare var fun: (inp: any) => AsyncGenerator ->fun : Symbol(fun, Decl(callWithSpread4.ts, 15, 11)) ->inp : Symbol(inp, Decl(callWithSpread4.ts, 15, 18)) +>fun : Symbol(fun, Decl(callWithSpread4.ts, 14, 11)) +>inp : Symbol(inp, Decl(callWithSpread4.ts, 14, 18)) +>AsyncGenerator : Symbol(AsyncGenerator, Decl(lib.es2018.asyncgenerator.d.ts, --, --)) pli( >pli : Symbol(pli, Decl(callWithSpread4.ts, 3, 13)) reads, ->reads : Symbol(reads, Decl(callWithSpread4.ts, 11, 11)) +>reads : Symbol(reads, Decl(callWithSpread4.ts, 10, 11)) ...gun, ->gun : Symbol(gun, Decl(callWithSpread4.ts, 13, 11)) +>gun : Symbol(gun, Decl(callWithSpread4.ts, 12, 11)) tr, ->tr : Symbol(tr, Decl(callWithSpread4.ts, 12, 11)) +>tr : Symbol(tr, Decl(callWithSpread4.ts, 11, 11)) fun, ->fun : Symbol(fun, Decl(callWithSpread4.ts, 15, 11)) +>fun : Symbol(fun, Decl(callWithSpread4.ts, 14, 11)) ...gz, ->gz : Symbol(gz, Decl(callWithSpread4.ts, 14, 11)) +>gz : Symbol(gz, Decl(callWithSpread4.ts, 13, 11)) writes ->writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) +>writes : Symbol(writes, Decl(callWithSpread4.ts, 9, 11)) ); declare function test(x: any, y: () => string): string | undefined; ->test : Symbol(test, Decl(callWithSpread4.ts, 23, 2)) ->x : Symbol(x, Decl(callWithSpread4.ts, 25, 22)) ->y : Symbol(y, Decl(callWithSpread4.ts, 25, 29)) +>test : Symbol(test, Decl(callWithSpread4.ts, 22, 2)) +>x : Symbol(x, Decl(callWithSpread4.ts, 24, 22)) +>y : Symbol(y, Decl(callWithSpread4.ts, 24, 29)) declare var anys: any[] ->anys : Symbol(anys, Decl(callWithSpread4.ts, 26, 11)) +>anys : Symbol(anys, Decl(callWithSpread4.ts, 25, 11)) test(...anys) ->test : Symbol(test, Decl(callWithSpread4.ts, 23, 2)) ->anys : Symbol(anys, Decl(callWithSpread4.ts, 26, 11)) +>test : Symbol(test, Decl(callWithSpread4.ts, 22, 2)) +>anys : Symbol(anys, Decl(callWithSpread4.ts, 25, 11)) pli(...[reads, writes, writes] as const) >pli : Symbol(pli, Decl(callWithSpread4.ts, 3, 13)) ->reads : Symbol(reads, Decl(callWithSpread4.ts, 11, 11)) ->writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) ->writes : Symbol(writes, Decl(callWithSpread4.ts, 10, 11)) +>reads : Symbol(reads, Decl(callWithSpread4.ts, 10, 11)) +>writes : Symbol(writes, Decl(callWithSpread4.ts, 9, 11)) +>writes : Symbol(writes, Decl(callWithSpread4.ts, 9, 11)) diff --git a/tests/baselines/reference/callWithSpread4.types b/tests/baselines/reference/callWithSpread4.types index 8ecb32c2c5bbc..5caef4eb70173 100644 --- a/tests/baselines/reference/callWithSpread4.types +++ b/tests/baselines/reference/callWithSpread4.types @@ -25,7 +25,6 @@ declare const pli: { (streams: ReadonlyArray): Promise; >streams : readonly (R | W | RW)[] - // commenting this out keeps the error the same, but provides definite ranges, which explains the weird bheaviour a little better (s1: R, s2: RW | W, ...streams: Array): Promise; >s1 : R >s2 : W | RW @@ -48,7 +47,7 @@ declare var gz: RW[] >gz : RW[] declare var fun: (inp: any) => AsyncGenerator ->fun : (inp: any) => any +>fun : (inp: any) => AsyncGenerator >inp : any pli( @@ -66,7 +65,7 @@ pli( >tr : W fun, ->fun : (inp: any) => any +>fun : (inp: any) => AsyncGenerator ...gz, >...gz : RW diff --git a/tests/baselines/reference/functionParameterArityMismatch.errors.txt b/tests/baselines/reference/functionParameterArityMismatch.errors.txt index 8cdbd37c4ab06..ad48650351dff 100644 --- a/tests/baselines/reference/functionParameterArityMismatch.errors.txt +++ b/tests/baselines/reference/functionParameterArityMismatch.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/functionParameterArityMismatch.ts(11,1): error TS2575: No o tests/cases/compiler/functionParameterArityMismatch.ts(12,1): error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(13,1): error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(14,22): error TS2554: Expected 0-6 arguments, but got 7. -tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: Expected 0-6 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: Expected 0-6 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/compiler/functionParameterArityMismatch.ts (8 errors) ==== @@ -40,5 +40,5 @@ tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: Expe !!! error TS2554: Expected 0-6 arguments, but got 7. f2(...[1], 2, 3, 4, 5, 6); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 0-6 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2556: Expected 0-6 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index 90d8dd0dd2841..b297930725887 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== @@ -18,5 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts:1:14: An argument for 's' was not provided. \ No newline at end of file +!!! error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index 1c92cbc84598b..ac48af890261f 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== @@ -18,5 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556 foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts:1:17: An argument for 's' was not provided. \ No newline at end of file +!!! error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index 2f6dc257798eb..31e00ed45aaa6 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== @@ -18,5 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts:1:14: An argument for 's' was not provided. \ No newline at end of file +!!! error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index 5b8242522227c..ce626f508e167 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== @@ -18,5 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 1 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts:1:14: An argument for 's1' was not provided. \ No newline at end of file +!!! error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt index 2e73e1a894a17..9dc59094263be 100644 --- a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt +++ b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number' is not an array type. @@ -8,7 +8,7 @@ tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number while (1) { bar = ~foo(...bar); ~~~~~~ -!!! error TS2556: Expected 0 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +!!! error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. ~~~ !!! error TS2461: Type 'number' is not an array type. } diff --git a/tests/baselines/reference/readonlyRestParameters.errors.txt b/tests/baselines/reference/readonlyRestParameters.errors.txt index dc3a16fc90c02..eda7f7a58e485 100644 --- a/tests/baselines/reference/readonlyRestParameters.errors.txt +++ b/tests/baselines/reference/readonlyRestParameters.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. +tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,15): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): error TS2542: Index signature in type 'readonly string[]' only permits reading. @@ -13,8 +13,7 @@ tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): erro function f1(...args: readonly string[]) { f0(...args); // Error ~~~~~~~ -!!! error TS2556: Expected 2 arguments, but after 0, found a non-tuple spread that must be passed to a rest parameter. -!!! related TS6210 tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts:1:13: An argument for 'a' was not provided. +!!! error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. f1('abc', 'def'); f1('abc', ...args); f1(...args); diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts index 955d5228d704a..8b3494520dd6e 100644 --- a/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts @@ -1,4 +1,5 @@ // @strict: true +// @target: esnext type R = { a: number } type W = { b: number } type RW = { a: number, b: number } From 33d00c9087a637f6714c5921d73848ff1b600ddf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 27 Apr 2021 16:30:05 -0700 Subject: [PATCH 5/8] Simplify and reword spread errors --- src/compiler/checker.ts | 34 +++++++++---------- src/compiler/diagnosticMessages.json | 6 +--- .../reference/callWithSpread2.errors.txt | 20 +++++------ .../reference/callWithSpread3.errors.txt | 22 ++++++------ .../reference/callWithSpread4.errors.txt | 14 +++----- .../reference/callWithSpread5.errors.txt | 14 ++++++++ tests/baselines/reference/callWithSpread5.js | 18 ++++++++++ .../reference/callWithSpread5.symbols | 27 +++++++++++++++ .../baselines/reference/callWithSpread5.types | 31 +++++++++++++++++ .../functionCalls/callWithSpread5.ts | 7 ++++ 10 files changed, 140 insertions(+), 53 deletions(-) create mode 100644 tests/baselines/reference/callWithSpread5.errors.txt create mode 100644 tests/baselines/reference/callWithSpread5.js create mode 100644 tests/baselines/reference/callWithSpread5.symbols create mode 100644 tests/baselines/reference/callWithSpread5.types create mode 100644 tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e6476bab5036d..ed82c115f5103 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28580,23 +28580,26 @@ namespace ts { } + const spreadIndex = getSpreadArgumentIndex(args); + const hasSpreadArgument = spreadIndex > -1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (hasSpreadArgument) { + return createDiagnosticForNode(args[spreadIndex], Diagnostics.A_spread_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + const hasRestParameter = some(signatures, hasEffectiveRestParameter); - const hasSpreadArgument = getSpreadArgumentIndex(args) > -1; const parameterRange = hasRestParameter ? min : min < max ? min + "-" + max : min; - const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_after_1_found_a_spread_that_must_be_passed_to_a_rest_parameter - : hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_after_1_found_a_spread_that_must_be_passed_to_a_rest_parameter - : hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 + const error = hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : Diagnostics.Expected_0_arguments_but_got_1; - if (min < args.length && args.length < max) { - // between min and max, but with no matching overload - return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); - } - else if (args.length < min && !hasSpreadArgument) { + if (args.length < min && !hasSpreadArgument) { // too short: put the error span on the call expression, not any of the args - const diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length) + const diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); const parameter = closestSignature?.declaration?.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; if (parameter) { const parameterError = createDiagnosticForNode( @@ -28611,20 +28614,15 @@ namespace ts { return diagnostic; } else { - // too long/spread; error goes on spread or on the excess parameters - const spreadIndex = getSpreadArgumentIndex(args) - const hasSpreadArgument = spreadIndex > -1 - const errorStart = hasSpreadArgument - ? Math.min(max, args.length - 1, spreadIndex) - : max; - const errorSpan = factory.createNodeArray(args.slice(errorStart)); + // too long; error goes on the excess parameters + const errorSpan = factory.createNodeArray(args.slice(max)); const pos = first(errorSpan).pos; let end = last(errorSpan).end; if (end === pos) { end++; } setTextRangePosEnd(errorSpan, pos, end); - return createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan, error, parameterRange, hasSpreadArgument ? spreadIndex : args.length); + return createDiagnosticForNodeArray(getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9700a6f2cc828..3e9985b4d1da1 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2386,14 +2386,10 @@ "category": "Error", "code": 2555 }, - "Expected {0} arguments, but after {1}, found a spread that must be passed to a rest parameter.": { + "A spread must either have a tuple type or be passed to a rest parameter.": { "category": "Error", "code": 2556 }, - "Expected at least {0} arguments, but after {1}, found a spread that must be passed to a rest parameter.": { - "category": "Error", - "code": 2557 - }, "Expected {0} type arguments, but got {1}.": { "category": "Error", "code": 2558 diff --git a/tests/baselines/reference/callWithSpread2.errors.txt b/tests/baselines/reference/callWithSpread2.errors.txt index 51b2877f4a3bb..863147032b944 100644 --- a/tests/baselines/reference/callWithSpread2.errors.txt +++ b/tests/baselines/reference/callWithSpread2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: Expected 1 arguments, but after 1, found a spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(27,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(28,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -9,10 +9,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,13): err tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,8): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: Expected 2-4 arguments, but after 1, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (12 errors) ==== @@ -40,10 +40,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err // extra arguments normal("g", ...ns) ~~~~~ -!!! error TS2556: Expected 1 arguments, but after 1, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. thunk(...ns) ~~~~~ -!!! error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. // bad all(...mixed) @@ -69,14 +69,14 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. prefix(...ns) // required parameters are required ~~~~~ -!!! error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. prefix(...mixed) ~~~~~~~~ -!!! error TS2556: Expected 1-3 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. prefix(...tuple) ~~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. prefix2("g", ...ns); ~~~~~ -!!! error TS2556: Expected 2-4 arguments, but after 1, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread3.errors.txt b/tests/baselines/reference/callWithSpread3.errors.txt index 24a438ed4a856..c8b1b39503460 100644 --- a/tests/baselines/reference/callWithSpread3.errors.txt +++ b/tests/baselines/reference/callWithSpread3.errors.txt @@ -4,12 +4,12 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(16,15): err tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(17,15): error TS2554: Expected 2 arguments, but got 6. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(18,12): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(19,5): error TS2554: Expected 2 arguments, but got 3. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(21,6): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(25,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts (12 errors) ==== @@ -46,16 +46,16 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): erro !!! error TS2554: Expected 2 arguments, but got 3. fs2_(...s_); // error on ...s_ ~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. fs2_(...s2n_); // error on ...s2n_ ~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. fs2_(...s_, ...s_); // error FIXME: bad error message - ~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. + ~~~~~ +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. + ~~~~~ +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_(...s2_); // error on ...s2_ ~~~~~~ @@ -66,8 +66,8 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): erro fs2_(...s2_, ...s_); fs2_(...s2_, ...s2_); fs2_(...s_, ...s2_); - ~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 2 arguments, but after 0, found a spread that must be passed to a rest parameter. + ~~~~~ +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. fs2n_(...s2n_); fs2n_(...s2); // fs2n_(...s2, ...n_); // FIXME: should compile diff --git a/tests/baselines/reference/callWithSpread4.errors.txt b/tests/baselines/reference/callWithSpread4.errors.txt index 27cd273ade6fa..a50d757dac4fd 100644 --- a/tests/baselines/reference/callWithSpread4.errors.txt +++ b/tests/baselines/reference/callWithSpread4.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(18,5): error TS2557: Expected at least 1 arguments, but after 1, found a spread that must be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(18,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (2 errors) ==== @@ -21,23 +21,19 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): erro pli( reads, ...gun, - ~~~~~~~ + ~~~~~~ +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tr, - ~~~~~~~ fun, - ~~~~~~~~ ...gz, - ~~~~~~~~~~ writes - ~~~~~~~~~~ -!!! error TS2557: Expected at least 1 arguments, but after 1, found a spread that must be passed to a rest parameter. ); declare function test(x: any, y: () => string): string | undefined; declare var anys: any[] test(...anys) ~~~~~~~ -!!! error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. pli(...[reads, writes, writes] as const) \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread5.errors.txt b/tests/baselines/reference/callWithSpread5.errors.txt new file mode 100644 index 0000000000000..dc81b52343a3c --- /dev/null +++ b/tests/baselines/reference/callWithSpread5.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts(7,4): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. + + +==== tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts (1 errors) ==== + declare const x: number + declare const nnnu: [number, number, number?] + declare const nntnnnt: [number, number] | [number, number, number] + declare function fn(a: number, b: number, bb: number, ...c: number[]): number + + fn(...nnnu, x) + fn(...nntnnnt, x) + ~~~~~~~~~~ +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. + \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread5.js b/tests/baselines/reference/callWithSpread5.js new file mode 100644 index 0000000000000..3b4d1c683110b --- /dev/null +++ b/tests/baselines/reference/callWithSpread5.js @@ -0,0 +1,18 @@ +//// [callWithSpread5.ts] +declare const x: number +declare const nnnu: [number, number, number?] +declare const nntnnnt: [number, number] | [number, number, number] +declare function fn(a: number, b: number, bb: number, ...c: number[]): number + +fn(...nnnu, x) +fn(...nntnnnt, x) + + +//// [callWithSpread5.js] +var __spreadArray = (this && this.__spreadArray) || function (to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) + to[j] = from[i]; + return to; +}; +fn.apply(void 0, __spreadArray(__spreadArray([], nnnu), [x])); +fn.apply(void 0, __spreadArray(__spreadArray([], nntnnnt), [x])); diff --git a/tests/baselines/reference/callWithSpread5.symbols b/tests/baselines/reference/callWithSpread5.symbols new file mode 100644 index 0000000000000..b3452ff611551 --- /dev/null +++ b/tests/baselines/reference/callWithSpread5.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts === +declare const x: number +>x : Symbol(x, Decl(callWithSpread5.ts, 0, 13)) + +declare const nnnu: [number, number, number?] +>nnnu : Symbol(nnnu, Decl(callWithSpread5.ts, 1, 13)) + +declare const nntnnnt: [number, number] | [number, number, number] +>nntnnnt : Symbol(nntnnnt, Decl(callWithSpread5.ts, 2, 13)) + +declare function fn(a: number, b: number, bb: number, ...c: number[]): number +>fn : Symbol(fn, Decl(callWithSpread5.ts, 2, 66)) +>a : Symbol(a, Decl(callWithSpread5.ts, 3, 20)) +>b : Symbol(b, Decl(callWithSpread5.ts, 3, 30)) +>bb : Symbol(bb, Decl(callWithSpread5.ts, 3, 41)) +>c : Symbol(c, Decl(callWithSpread5.ts, 3, 53)) + +fn(...nnnu, x) +>fn : Symbol(fn, Decl(callWithSpread5.ts, 2, 66)) +>nnnu : Symbol(nnnu, Decl(callWithSpread5.ts, 1, 13)) +>x : Symbol(x, Decl(callWithSpread5.ts, 0, 13)) + +fn(...nntnnnt, x) +>fn : Symbol(fn, Decl(callWithSpread5.ts, 2, 66)) +>nntnnnt : Symbol(nntnnnt, Decl(callWithSpread5.ts, 2, 13)) +>x : Symbol(x, Decl(callWithSpread5.ts, 0, 13)) + diff --git a/tests/baselines/reference/callWithSpread5.types b/tests/baselines/reference/callWithSpread5.types new file mode 100644 index 0000000000000..b3bd35312d6bf --- /dev/null +++ b/tests/baselines/reference/callWithSpread5.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts === +declare const x: number +>x : number + +declare const nnnu: [number, number, number?] +>nnnu : [number, number, number?] + +declare const nntnnnt: [number, number] | [number, number, number] +>nntnnnt : [number, number] | [number, number, number] + +declare function fn(a: number, b: number, bb: number, ...c: number[]): number +>fn : (a: number, b: number, bb: number, ...c: number[]) => number +>a : number +>b : number +>bb : number +>c : number[] + +fn(...nnnu, x) +>fn(...nnnu, x) : number +>fn : (a: number, b: number, bb: number, ...c: number[]) => number +>...nnnu : number +>nnnu : [number, number, number?] +>x : number + +fn(...nntnnnt, x) +>fn(...nntnnnt, x) : number +>fn : (a: number, b: number, bb: number, ...c: number[]) => number +>...nntnnnt : number +>nntnnnt : [number, number] | [number, number, number] +>x : number + diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts new file mode 100644 index 0000000000000..924d66fe76a19 --- /dev/null +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts @@ -0,0 +1,7 @@ +declare const x: number +declare const nnnu: [number, number, number?] +declare const nntnnnt: [number, number] | [number, number, number] +declare function fn(a: number, b: number, bb: number, ...c: number[]): number + +fn(...nnnu, x) +fn(...nntnnnt, x) From 30e131afb6e9043416d1c436914ef50c51115e12 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 27 Apr 2021 16:33:44 -0700 Subject: [PATCH 6/8] handle spreads first --- src/compiler/checker.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ed82c115f5103..2a7a6525fd792 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28559,6 +28559,10 @@ namespace ts { } function getArgumentArityError(node: CallLikeExpression, signatures: readonly Signature[], args: readonly Expression[]) { + const spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return createDiagnosticForNode(args[spreadIndex], Diagnostics.A_spread_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } let min = Number.POSITIVE_INFINITY; // smallest parameter count let max = Number.NEGATIVE_INFINITY; // larger parameter count let maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments @@ -28574,22 +28578,10 @@ namespace ts { closestSignature = sig; } max = Math.max(max, maxParameter); - // shortest parameter count *longer than the call*/longest parametercount *shorter than the call* + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* if (minParameter < args.length && minParameter > maxBelow) maxBelow = minParameter; if (args.length < maxParameter && maxParameter < minAbove) minAbove = maxParameter; } - - - const spreadIndex = getSpreadArgumentIndex(args); - const hasSpreadArgument = spreadIndex > -1; - if (min < args.length && args.length < max) { - // between min and max, but with no matching overload - return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); - } - else if (hasSpreadArgument) { - return createDiagnosticForNode(args[spreadIndex], Diagnostics.A_spread_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); - } - const hasRestParameter = some(signatures, hasEffectiveRestParameter); const parameterRange = hasRestParameter ? min : min < max ? min + "-" + max @@ -28597,7 +28589,11 @@ namespace ts { const error = hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : Diagnostics.Expected_0_arguments_but_got_1; - if (args.length < min && !hasSpreadArgument) { + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { // too short: put the error span on the call expression, not any of the args const diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); const parameter = closestSignature?.declaration?.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; From 8a265fb4181bbae0ba5a54fd0bdc7329c6b855ae Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 27 Apr 2021 16:36:08 -0700 Subject: [PATCH 7/8] update baselines --- tests/baselines/reference/callOverload.errors.txt | 4 ++-- .../reference/functionParameterArityMismatch.errors.txt | 6 +++--- tests/baselines/reference/iteratorSpreadInCall.errors.txt | 4 ++-- tests/baselines/reference/iteratorSpreadInCall10.errors.txt | 4 ++-- tests/baselines/reference/iteratorSpreadInCall2.errors.txt | 4 ++-- tests/baselines/reference/iteratorSpreadInCall4.errors.txt | 4 ++-- tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt | 4 ++-- tests/baselines/reference/readonlyRestParameters.errors.txt | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/baselines/reference/callOverload.errors.txt b/tests/baselines/reference/callOverload.errors.txt index b11d90f2b9ee9..85034d3bf76d5 100644 --- a/tests/baselines/reference/callOverload.errors.txt +++ b/tests/baselines/reference/callOverload.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(7,7): error TS2554: Expected 1 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(8,15): error TS2554: Expected 2 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(10,1): error TS2555: Expected at least 1 arguments, but got 0. -tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callOverload.ts (4 errors) ==== @@ -24,4 +24,4 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. withRest(...n); ~~~~ -!!! error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/functionParameterArityMismatch.errors.txt b/tests/baselines/reference/functionParameterArityMismatch.errors.txt index ad48650351dff..ab5a3f2900a2d 100644 --- a/tests/baselines/reference/functionParameterArityMismatch.errors.txt +++ b/tests/baselines/reference/functionParameterArityMismatch.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/functionParameterArityMismatch.ts(11,1): error TS2575: No o tests/cases/compiler/functionParameterArityMismatch.ts(12,1): error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(13,1): error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(14,22): error TS2554: Expected 0-6 arguments, but got 7. -tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: Expected 0-6 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/compiler/functionParameterArityMismatch.ts (8 errors) ==== @@ -39,6 +39,6 @@ tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: Expe ~ !!! error TS2554: Expected 0-6 arguments, but got 7. f2(...[1], 2, 3, 4, 5, 6); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 0-6 arguments, but after 0, found a spread that must be passed to a rest parameter. + ~~~~~~ +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index b297930725887..a412ab78724d1 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index ac48af890261f..896e81207ba0d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556 foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index 31e00ed45aaa6..d694f4457e95c 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index ce626f508e167..0ae06ed2d8a79 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2557: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 1 arguments, but after 0, found a spread that must be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt index 9dc59094263be..b8fd242de323a 100644 --- a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt +++ b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number' is not an array type. @@ -8,7 +8,7 @@ tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number while (1) { bar = ~foo(...bar); ~~~~~~ -!!! error TS2556: Expected 0 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. ~~~ !!! error TS2461: Type 'number' is not an array type. } diff --git a/tests/baselines/reference/readonlyRestParameters.errors.txt b/tests/baselines/reference/readonlyRestParameters.errors.txt index eda7f7a58e485..6ac1d78a8c838 100644 --- a/tests/baselines/reference/readonlyRestParameters.errors.txt +++ b/tests/baselines/reference/readonlyRestParameters.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,15): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): error TS2542: Index signature in type 'readonly string[]' only permits reading. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): erro function f1(...args: readonly string[]) { f0(...args); // Error ~~~~~~~ -!!! error TS2556: Expected 2 arguments, but after 0, found a spread that must be passed to a rest parameter. +!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. f1('abc', 'def'); f1('abc', ...args); f1(...args); From 24583bf7d91015f607ffff985389a6e3032e6809 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 29 Apr 2021 14:11:55 -0700 Subject: [PATCH 8/8] Address PR comments --- src/compiler/checker.ts | 6 +++--- src/compiler/diagnosticMessages.json | 4 ++-- .../reference/callOverload.errors.txt | 4 ++-- .../reference/callWithSpread2.errors.txt | 20 +++++++++---------- .../reference/callWithSpread3.errors.txt | 20 +++++++++---------- tests/baselines/reference/callWithSpread3.js | 8 ++++---- .../reference/callWithSpread3.symbols | 4 ++-- .../baselines/reference/callWithSpread3.types | 4 ++-- .../reference/callWithSpread4.errors.txt | 8 ++++---- .../reference/callWithSpread5.errors.txt | 4 ++-- .../functionParameterArityMismatch.errors.txt | 4 ++-- .../reference/iteratorSpreadInCall.errors.txt | 4 ++-- .../iteratorSpreadInCall10.errors.txt | 4 ++-- .../iteratorSpreadInCall2.errors.txt | 4 ++-- .../iteratorSpreadInCall4.errors.txt | 4 ++-- .../noImplicitAnyLoopCrash.errors.txt | 4 ++-- .../readonlyRestParameters.errors.txt | 4 ++-- .../functionCalls/callWithSpread3.ts | 4 ++-- 18 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2a7a6525fd792..3d11cbdfc8c99 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28561,10 +28561,10 @@ namespace ts { function getArgumentArityError(node: CallLikeExpression, signatures: readonly Signature[], args: readonly Expression[]) { const spreadIndex = getSpreadArgumentIndex(args); if (spreadIndex > -1) { - return createDiagnosticForNode(args[spreadIndex], Diagnostics.A_spread_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + return createDiagnosticForNode(args[spreadIndex], Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); } let min = Number.POSITIVE_INFINITY; // smallest parameter count - let max = Number.NEGATIVE_INFINITY; // larger parameter count + let max = Number.NEGATIVE_INFINITY; // largest parameter count let maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments let minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments @@ -28572,7 +28572,7 @@ namespace ts { for (const sig of signatures) { const minParameter = getMinArgumentCount(sig); const maxParameter = getParameterCount(sig); - // shortest/longest parameter counts + // smallest/largest parameter counts if (minParameter < min) { min = minParameter; closestSignature = sig; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3e9985b4d1da1..4ffc5f53e384a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -526,7 +526,7 @@ "'extends' clause already seen.": { "category": "Error", "code": 1172 - }, + }, "'extends' clause must precede 'implements' clause.": { "category": "Error", "code": 1173 @@ -2386,7 +2386,7 @@ "category": "Error", "code": 2555 }, - "A spread must either have a tuple type or be passed to a rest parameter.": { + "A spread argument must either have a tuple type or be passed to a rest parameter.": { "category": "Error", "code": 2556 }, diff --git a/tests/baselines/reference/callOverload.errors.txt b/tests/baselines/reference/callOverload.errors.txt index 85034d3bf76d5..c5b171aca492f 100644 --- a/tests/baselines/reference/callOverload.errors.txt +++ b/tests/baselines/reference/callOverload.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(7,7): error TS2554: Expected 1 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(8,15): error TS2554: Expected 2 arguments, but got 4. tests/cases/conformance/expressions/functionCalls/callOverload.ts(10,1): error TS2555: Expected at least 1 arguments, but got 0. -tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callOverload.ts (4 errors) ==== @@ -24,4 +24,4 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. withRest(...n); ~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread2.errors.txt b/tests/baselines/reference/callWithSpread2.errors.txt index 863147032b944..0361c2aef336d 100644 --- a/tests/baselines/reference/callWithSpread2.errors.txt +++ b/tests/baselines/reference/callWithSpread2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,13): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(24,7): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(27,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(28,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. @@ -9,10 +9,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,13): err tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,8): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,8): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,8): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (12 errors) ==== @@ -40,10 +40,10 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err // extra arguments normal("g", ...ns) ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. thunk(...ns) ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. // bad all(...mixed) @@ -69,14 +69,14 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,14): err !!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. prefix(...ns) // required parameters are required ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. prefix(...mixed) ~~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. prefix(...tuple) ~~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. prefix2("g", ...ns); ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread3.errors.txt b/tests/baselines/reference/callWithSpread3.errors.txt index c8b1b39503460..34e0112003ee7 100644 --- a/tests/baselines/reference/callWithSpread3.errors.txt +++ b/tests/baselines/reference/callWithSpread3.errors.txt @@ -4,12 +4,12 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(16,15): err tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(17,15): error TS2554: Expected 2 arguments, but got 6. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(18,12): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(19,5): error TS2554: Expected 2 arguments, but got 3. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(20,6): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(21,6): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(22,6): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(23,6): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(25,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts (12 errors) ==== @@ -46,16 +46,16 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): erro !!! error TS2554: Expected 2 arguments, but got 3. fs2_(...s_); // error on ...s_ ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. fs2_(...s2n_); // error on ...s2n_ ~~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. - fs2_(...s_, ...s_); // error FIXME: bad error message + fs2_(...s_, ...s_); // error on ...s_ ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. - fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. + fs2_(...s_, ...s_, ...s_); // error on ...s_ ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_(...s2_); // error on ...s2_ ~~~~~~ @@ -67,7 +67,7 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts(31,6): erro fs2_(...s2_, ...s2_); fs2_(...s_, ...s2_); ~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. fs2n_(...s2n_); fs2n_(...s2); // fs2n_(...s2, ...n_); // FIXME: should compile diff --git a/tests/baselines/reference/callWithSpread3.js b/tests/baselines/reference/callWithSpread3.js index f94e74b1dd434..fbd11df511ee2 100644 --- a/tests/baselines/reference/callWithSpread3.js +++ b/tests/baselines/reference/callWithSpread3.js @@ -20,8 +20,8 @@ fs2(...s2, 'a'); // error on 'a' fs2(...s3); // error on ...s3 fs2_(...s_); // error on ...s_ fs2_(...s2n_); // error on ...s2n_ -fs2_(...s_, ...s_); // error FIXME: bad error message -fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message +fs2_(...s_, ...s_); // error on ...s_ +fs2_(...s_, ...s_, ...s_); // error on ...s_ // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_(...s2_); // error on ...s2_ @@ -51,8 +51,8 @@ fs2.apply(void 0, __spreadArray(__spreadArray([], s2), ['a'])); // error on 'a' fs2.apply(void 0, s3); // error on ...s3 fs2_.apply(void 0, s_); // error on ...s_ fs2_.apply(void 0, s2n_); // error on ...s2n_ -fs2_.apply(void 0, __spreadArray(__spreadArray([], s_), s_)); // error FIXME: bad error message -fs2_.apply(void 0, __spreadArray(__spreadArray(__spreadArray([], s_), s_), s_)); // error FIXME: worse error message +fs2_.apply(void 0, __spreadArray(__spreadArray([], s_), s_)); // error on ...s_ +fs2_.apply(void 0, __spreadArray(__spreadArray(__spreadArray([], s_), s_), s_)); // error on ...s_ // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_.apply(void 0, s2_); // error on ...s2_ // ok diff --git a/tests/baselines/reference/callWithSpread3.symbols b/tests/baselines/reference/callWithSpread3.symbols index e305b1d03ed6d..076c10a178d31 100644 --- a/tests/baselines/reference/callWithSpread3.symbols +++ b/tests/baselines/reference/callWithSpread3.symbols @@ -75,12 +75,12 @@ fs2_(...s2n_); // error on ...s2n_ >fs2_ : Symbol(fs2_, Decl(callWithSpread3.ts, 7, 49)) >s2n_ : Symbol(s2n_, Decl(callWithSpread3.ts, 5, 13)) -fs2_(...s_, ...s_); // error FIXME: bad error message +fs2_(...s_, ...s_); // error on ...s_ >fs2_ : Symbol(fs2_, Decl(callWithSpread3.ts, 7, 49)) >s_ : Symbol(s_, Decl(callWithSpread3.ts, 3, 13)) >s_ : Symbol(s_, Decl(callWithSpread3.ts, 3, 13)) -fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message +fs2_(...s_, ...s_, ...s_); // error on ...s_ >fs2_ : Symbol(fs2_, Decl(callWithSpread3.ts, 7, 49)) >s_ : Symbol(s_, Decl(callWithSpread3.ts, 3, 13)) >s_ : Symbol(s_, Decl(callWithSpread3.ts, 3, 13)) diff --git a/tests/baselines/reference/callWithSpread3.types b/tests/baselines/reference/callWithSpread3.types index dc7c7b4378772..3ddc98c66c824 100644 --- a/tests/baselines/reference/callWithSpread3.types +++ b/tests/baselines/reference/callWithSpread3.types @@ -103,7 +103,7 @@ fs2_(...s2n_); // error on ...s2n_ >...s2n_ : string | number >s2n_ : [string, string, ...number[]] -fs2_(...s_, ...s_); // error FIXME: bad error message +fs2_(...s_, ...s_); // error on ...s_ >fs2_(...s_, ...s_) : void >fs2_ : (a: string, b: string, ...c: string[]) => void >...s_ : string @@ -111,7 +111,7 @@ fs2_(...s_, ...s_); // error FIXME: bad error message >...s_ : string >s_ : string[] -fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message +fs2_(...s_, ...s_, ...s_); // error on ...s_ >fs2_(...s_, ...s_, ...s_) : void >fs2_ : (a: string, b: string, ...c: string[]) => void >...s_ : string diff --git a/tests/baselines/reference/callWithSpread4.errors.txt b/tests/baselines/reference/callWithSpread4.errors.txt index a50d757dac4fd..d4d67faf14a23 100644 --- a/tests/baselines/reference/callWithSpread4.errors.txt +++ b/tests/baselines/reference/callWithSpread4.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(18,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. -tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(18,5): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts (2 errors) ==== @@ -22,7 +22,7 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): erro reads, ...gun, ~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tr, fun, ...gz, @@ -33,7 +33,7 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread4.ts(27,6): erro declare var anys: any[] test(...anys) ~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. pli(...[reads, writes, writes] as const) \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread5.errors.txt b/tests/baselines/reference/callWithSpread5.errors.txt index dc81b52343a3c..28640ea5a3c99 100644 --- a/tests/baselines/reference/callWithSpread5.errors.txt +++ b/tests/baselines/reference/callWithSpread5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts(7,4): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts(7,4): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread5.ts(7,4): error fn(...nnnu, x) fn(...nntnnnt, x) ~~~~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/functionParameterArityMismatch.errors.txt b/tests/baselines/reference/functionParameterArityMismatch.errors.txt index ab5a3f2900a2d..85a1e8860c724 100644 --- a/tests/baselines/reference/functionParameterArityMismatch.errors.txt +++ b/tests/baselines/reference/functionParameterArityMismatch.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/functionParameterArityMismatch.ts(11,1): error TS2575: No o tests/cases/compiler/functionParameterArityMismatch.ts(12,1): error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(13,1): error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. tests/cases/compiler/functionParameterArityMismatch.ts(14,22): error TS2554: Expected 0-6 arguments, but got 7. -tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/compiler/functionParameterArityMismatch.ts (8 errors) ==== @@ -40,5 +40,5 @@ tests/cases/compiler/functionParameterArityMismatch.ts(15,4): error TS2556: A sp !!! error TS2554: Expected 0-6 arguments, but got 7. f2(...[1], 2, 3, 4, 5, 6); ~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index a412ab78724d1..f126c6e766d23 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index 896e81207ba0d..556e9e2606d00 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,5): error TS2556 foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index d694f4457e95c..772d12f4ebca7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index 0ae06ed2d8a79..c6df4f50c7807 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,5): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. \ No newline at end of file +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt index b8fd242de323a..d5bc065f54aef 100644 --- a/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt +++ b/tests/baselines/reference/noImplicitAnyLoopCrash.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,16): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number' is not an array type. @@ -8,7 +8,7 @@ tests/cases/compiler/noImplicitAnyLoopCrash.ts(4,19): error TS2461: Type 'number while (1) { bar = ~foo(...bar); ~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. ~~~ !!! error TS2461: Type 'number' is not an array type. } diff --git a/tests/baselines/reference/readonlyRestParameters.errors.txt b/tests/baselines/reference/readonlyRestParameters.errors.txt index 6ac1d78a8c838..e9a5d0adff752 100644 --- a/tests/baselines/reference/readonlyRestParameters.errors.txt +++ b/tests/baselines/reference/readonlyRestParameters.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,8): error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,15): error TS2554: Expected 2 arguments, but got 3. tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): error TS2542: Index signature in type 'readonly string[]' only permits reading. @@ -13,7 +13,7 @@ tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): erro function f1(...args: readonly string[]) { f0(...args); // Error ~~~~~~~ -!!! error TS2556: A spread must either have a tuple type or be passed to a rest parameter. +!!! error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter. f1('abc', 'def'); f1('abc', ...args); f1(...args); diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts index 88f9af46df5a4..1ee060b727f6c 100644 --- a/tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread3.ts @@ -19,8 +19,8 @@ fs2(...s2, 'a'); // error on 'a' fs2(...s3); // error on ...s3 fs2_(...s_); // error on ...s_ fs2_(...s2n_); // error on ...s2n_ -fs2_(...s_, ...s_); // error FIXME: bad error message -fs2_(...s_, ...s_, ...s_); // error FIXME: worse error message +fs2_(...s_, ...s_); // error on ...s_ +fs2_(...s_, ...s_, ...s_); // error on ...s_ // fs2n_(...s2, ...s_); // FIXME: should be a type error fs2n_(...s2_); // error on ...s2_