From ef89d26dc8c163e30e1c98b742754f1d8ed875e7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 18 Jan 2019 09:34:47 -0800 Subject: [PATCH] Accept new baselines --- .../readonlyRestParameters.errors.txt | 40 ++++++ .../reference/readonlyRestParameters.js | 73 +++++++++++ .../reference/readonlyRestParameters.symbols | 81 ++++++++++++ .../reference/readonlyRestParameters.types | 116 ++++++++++++++++++ 4 files changed, 310 insertions(+) create mode 100644 tests/baselines/reference/readonlyRestParameters.errors.txt create mode 100644 tests/baselines/reference/readonlyRestParameters.js create mode 100644 tests/baselines/reference/readonlyRestParameters.symbols create mode 100644 tests/baselines/reference/readonlyRestParameters.types diff --git a/tests/baselines/reference/readonlyRestParameters.errors.txt b/tests/baselines/reference/readonlyRestParameters.errors.txt new file mode 100644 index 00000000000..3a343276b4e --- /dev/null +++ b/tests/baselines/reference/readonlyRestParameters.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,5): error TS2556: Expected 2 arguments, but got 0 or more. +tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,5): 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. + + +==== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts (3 errors) ==== + function f0(a: string, b: string) { + f0(a, b); + f1(a, b); + f2(a, b); + } + + function f1(...args: readonly string[]) { + f0(...args); // Error + ~~~~~~~~~~~ +!!! error TS2556: Expected 2 arguments, but got 0 or more. +!!! related TS6210 tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts:1:13: An argument for 'a' was not provided. + f1('abc', 'def'); + f1('abc', ...args); + f1(...args); + } + + function f2(...args: readonly [string, string]) { + f0(...args); + f1('abc', 'def'); + f1('abc', ...args); + f1(...args); + f2('abc', 'def'); + f2('abc', ...args); // Error + ~~~~~~~~~~~~~~~~~~ +!!! error TS2554: Expected 2 arguments, but got 3. + f2(...args); + } + + function f4(...args: readonly string[]) { + args[0] = 'abc'; // Error + ~~~~~~~ +!!! error TS2542: Index signature in type 'readonly string[]' only permits reading. + } + \ No newline at end of file diff --git a/tests/baselines/reference/readonlyRestParameters.js b/tests/baselines/reference/readonlyRestParameters.js new file mode 100644 index 00000000000..f6ccaf6081d --- /dev/null +++ b/tests/baselines/reference/readonlyRestParameters.js @@ -0,0 +1,73 @@ +//// [readonlyRestParameters.ts] +function f0(a: string, b: string) { + f0(a, b); + f1(a, b); + f2(a, b); +} + +function f1(...args: readonly string[]) { + f0(...args); // Error + f1('abc', 'def'); + f1('abc', ...args); + f1(...args); +} + +function f2(...args: readonly [string, string]) { + f0(...args); + f1('abc', 'def'); + f1('abc', ...args); + f1(...args); + f2('abc', 'def'); + f2('abc', ...args); // Error + f2(...args); +} + +function f4(...args: readonly string[]) { + args[0] = 'abc'; // Error +} + + +//// [readonlyRestParameters.js] +"use strict"; +function f0(a, b) { + f0(a, b); + f1(a, b); + f2(a, b); +} +function f1() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + f0.apply(void 0, args); // Error + f1('abc', 'def'); + f1.apply(void 0, ['abc'].concat(args)); + f1.apply(void 0, args); +} +function f2() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + f0.apply(void 0, args); + f1('abc', 'def'); + f1.apply(void 0, ['abc'].concat(args)); + f1.apply(void 0, args); + f2('abc', 'def'); + f2.apply(void 0, ['abc'].concat(args)); // Error + f2.apply(void 0, args); +} +function f4() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + args[0] = 'abc'; // Error +} + + +//// [readonlyRestParameters.d.ts] +declare function f0(a: string, b: string): void; +declare function f1(...args: readonly string[]): void; +declare function f2(...args: readonly [string, string]): void; +declare function f4(...args: readonly string[]): void; diff --git a/tests/baselines/reference/readonlyRestParameters.symbols b/tests/baselines/reference/readonlyRestParameters.symbols new file mode 100644 index 00000000000..f33d6014ad1 --- /dev/null +++ b/tests/baselines/reference/readonlyRestParameters.symbols @@ -0,0 +1,81 @@ +=== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts === +function f0(a: string, b: string) { +>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0)) +>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12)) +>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22)) + + f0(a, b); +>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0)) +>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12)) +>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22)) + + f1(a, b); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) +>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12)) +>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22)) + + f2(a, b); +>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1)) +>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12)) +>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22)) +} + +function f1(...args: readonly string[]) { +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12)) + + f0(...args); // Error +>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12)) + + f1('abc', 'def'); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) + + f1('abc', ...args); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12)) + + f1(...args); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12)) +} + +function f2(...args: readonly [string, string]) { +>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12)) + + f0(...args); +>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12)) + + f1('abc', 'def'); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) + + f1('abc', ...args); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12)) + + f1(...args); +>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12)) + + f2('abc', 'def'); +>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1)) + + f2('abc', ...args); // Error +>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12)) + + f2(...args); +>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12)) +} + +function f4(...args: readonly string[]) { +>f4 : Symbol(f4, Decl(readonlyRestParameters.ts, 21, 1)) +>args : Symbol(args, Decl(readonlyRestParameters.ts, 23, 12)) + + args[0] = 'abc'; // Error +>args : Symbol(args, Decl(readonlyRestParameters.ts, 23, 12)) +} + diff --git a/tests/baselines/reference/readonlyRestParameters.types b/tests/baselines/reference/readonlyRestParameters.types new file mode 100644 index 00000000000..c5a63630b0d --- /dev/null +++ b/tests/baselines/reference/readonlyRestParameters.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts === +function f0(a: string, b: string) { +>f0 : (a: string, b: string) => void +>a : string +>b : string + + f0(a, b); +>f0(a, b) : void +>f0 : (a: string, b: string) => void +>a : string +>b : string + + f1(a, b); +>f1(a, b) : void +>f1 : (...args: readonly string[]) => void +>a : string +>b : string + + f2(a, b); +>f2(a, b) : void +>f2 : (args_0: string, args_1: string) => void +>a : string +>b : string +} + +function f1(...args: readonly string[]) { +>f1 : (...args: readonly string[]) => void +>args : readonly string[] + + f0(...args); // Error +>f0(...args) : void +>f0 : (a: string, b: string) => void +>...args : string +>args : readonly string[] + + f1('abc', 'def'); +>f1('abc', 'def') : void +>f1 : (...args: readonly string[]) => void +>'abc' : "abc" +>'def' : "def" + + f1('abc', ...args); +>f1('abc', ...args) : void +>f1 : (...args: readonly string[]) => void +>'abc' : "abc" +>...args : string +>args : readonly string[] + + f1(...args); +>f1(...args) : void +>f1 : (...args: readonly string[]) => void +>...args : string +>args : readonly string[] +} + +function f2(...args: readonly [string, string]) { +>f2 : (args_0: string, args_1: string) => void +>args : readonly [string, string] + + f0(...args); +>f0(...args) : void +>f0 : (a: string, b: string) => void +>...args : string +>args : readonly [string, string] + + f1('abc', 'def'); +>f1('abc', 'def') : void +>f1 : (...args: readonly string[]) => void +>'abc' : "abc" +>'def' : "def" + + f1('abc', ...args); +>f1('abc', ...args) : void +>f1 : (...args: readonly string[]) => void +>'abc' : "abc" +>...args : string +>args : readonly [string, string] + + f1(...args); +>f1(...args) : void +>f1 : (...args: readonly string[]) => void +>...args : string +>args : readonly [string, string] + + f2('abc', 'def'); +>f2('abc', 'def') : void +>f2 : (args_0: string, args_1: string) => void +>'abc' : "abc" +>'def' : "def" + + f2('abc', ...args); // Error +>f2('abc', ...args) : void +>f2 : (args_0: string, args_1: string) => void +>'abc' : "abc" +>...args : string +>args : readonly [string, string] + + f2(...args); +>f2(...args) : void +>f2 : (args_0: string, args_1: string) => void +>...args : string +>args : readonly [string, string] +} + +function f4(...args: readonly string[]) { +>f4 : (...args: readonly string[]) => void +>args : readonly string[] + + args[0] = 'abc'; // Error +>args[0] = 'abc' : "abc" +>args[0] : string +>args : readonly string[] +>0 : 0 +>'abc' : "abc" +} +