From e4f416eb38f3b0eaddc67e350e11ee351cd51d20 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Wed, 13 May 2015 09:35:20 +0800 Subject: [PATCH 01/11] Adds an ignore on projectOutput --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f487ea6dd29ba..f28b2ffd329ce 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ tests/services/baselines/local/* tests/baselines/prototyping/local/* tests/baselines/rwc/* tests/baselines/test262/* +tests/baselines/reference/projectOutput/* tests/baselines/local/projectOutput/* tests/services/baselines/prototyping/local/* tests/services/browser/typescriptServices.js From fdfbcf6ffcfe6fd69f27a79696aba245998b436f Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Wed, 13 May 2015 09:36:05 +0800 Subject: [PATCH 02/11] Adds tests --- .../reference/newWithSpread.errors.txt | 165 ++++++ tests/baselines/reference/newWithSpread.js | 164 ++++++ tests/baselines/reference/newWithSpreadES5.js | 164 ++++++ .../reference/newWithSpreadES5.symbols | 258 ++++++++++ .../reference/newWithSpreadES5.types | 471 ++++++++++++++++++ tests/baselines/reference/newWithSpreadES6.js | 155 ++++++ .../reference/newWithSpreadES6.symbols | 258 ++++++++++ .../reference/newWithSpreadES6.types | 471 ++++++++++++++++++ .../functionCalls/newWithSpread.ts | 90 ++++ .../functionCalls/newWithSpreadES5.ts | 91 ++++ .../functionCalls/newWithSpreadES6.ts | 91 ++++ 11 files changed, 2378 insertions(+) create mode 100644 tests/baselines/reference/newWithSpread.errors.txt create mode 100644 tests/baselines/reference/newWithSpread.js create mode 100644 tests/baselines/reference/newWithSpreadES5.js create mode 100644 tests/baselines/reference/newWithSpreadES5.symbols create mode 100644 tests/baselines/reference/newWithSpreadES5.types create mode 100644 tests/baselines/reference/newWithSpreadES6.js create mode 100644 tests/baselines/reference/newWithSpreadES6.symbols create mode 100644 tests/baselines/reference/newWithSpreadES6.types create mode 100644 tests/cases/conformance/expressions/functionCalls/newWithSpread.ts create mode 100644 tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts create mode 100644 tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts diff --git a/tests/baselines/reference/newWithSpread.errors.txt b/tests/baselines/reference/newWithSpread.errors.txt new file mode 100644 index 0000000000000..2b02d91fccc3c --- /dev/null +++ b/tests/baselines/reference/newWithSpread.errors.txt @@ -0,0 +1,165 @@ +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(34,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(35,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(39,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(40,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(44,15): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(45,15): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(49,17): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(50,17): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(54,18): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(55,18): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(59,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(60,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(64,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(65,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(69,20): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(70,20): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(74,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(75,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(79,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(80,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(84,27): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(85,27): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(89,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(90,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + +==== tests/cases/conformance/expressions/functionCalls/newWithSpread.ts (24 errors) ==== + + function f(x: number, y: number, ...z: string[]) { + } + + interface A { + f: { + new (x: number, y: number, ...z: string[]); + } + } + + class B { + constructor(x: number, y: number, ...z: string[]) {} + } + + interface C { + "a-b": typeof B; + } + + interface D { + 1: typeof B; + } + + var a: string[]; + var b: A; + var c: C; + var d: A[]; + var e: { [key: string]: A }; + var g: C[]; + var h: { [key: string]: C }; + var i: C[][]; + + // Basic expression + new f(1, 2, "string"); + new f(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new f(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Call expression + new f(1, 2, "string")(); + new f(1, 2, ...a)(); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new f(1, 2, ...a, "string")(); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Property access expression + new b.f(1, 2, "string"); + new b.f(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new b.f(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Parenthesised expression + new (b.f)(1, 2, "string"); + new (b.f)(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new (b.f)(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Element access expression + new d[1].f(1, 2, "string"); + new d[1].f(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new d[1].f(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Element access expression with a punctuated key + new e["a-b"].f(1, 2, "string"); + new e["a-b"].f(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new e["a-b"].f(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Basic expression + new B(1, 2, "string"); + new B(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new B(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Property access expression + new c["a-b"](1, 2, "string"); + new c["a-b"](1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new c["a-b"](1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Parenthesised expression + new (c["a-b"])(1, 2, "string"); + new (c["a-b"])(1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new (c["a-b"])(1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Element access expression + new g[1]["a-b"](1, 2, "string"); + new g[1]["a-b"](1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new g[1]["a-b"](1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Element access expression with a punctuated key + new h["a-b"]["a-b"](1, 2, "string"); + new h["a-b"]["a-b"](1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new h["a-b"]["a-b"](1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + + // Element access expression with a number + new i["a-b"][1](1, 2, "string"); + new i["a-b"][1](1, 2, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new i["a-b"][1](1, 2, ...a, "string"); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/newWithSpread.js b/tests/baselines/reference/newWithSpread.js new file mode 100644 index 0000000000000..6fba9e9a9e81b --- /dev/null +++ b/tests/baselines/reference/newWithSpread.js @@ -0,0 +1,164 @@ +//// [newWithSpread.ts] + +function f(x: number, y: number, ...z: string[]) { +} + +interface A { + f: { + new (x: number, y: number, ...z: string[]); + } +} + +class B { + constructor(x: number, y: number, ...z: string[]) {} +} + +interface C { + "a-b": typeof B; +} + +interface D { + 1: typeof B; +} + +var a: string[]; +var b: A; +var c: C; +var d: A[]; +var e: { [key: string]: A }; +var g: C[]; +var h: { [key: string]: C }; +var i: C[][]; + +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); + +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); + +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); + +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); + +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); + +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); + +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); + +//// [newWithSpread.js] +function f(x, y) { + var z = []; + for (var _i = 2; _i < arguments.length; _i++) { + z[_i - 2] = arguments[_i]; + } +} +var B = (function () { + function B(x, y) { + var z = []; + for (var _i = 2; _i < arguments.length; _i++) { + z[_i - 2] = arguments[_i]; + } + } + return B; +})(); +var a; +var b; +var c; +var d; +var e; +var g; +var h; +var i; +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); diff --git a/tests/baselines/reference/newWithSpreadES5.js b/tests/baselines/reference/newWithSpreadES5.js new file mode 100644 index 0000000000000..e463f0aaeead8 --- /dev/null +++ b/tests/baselines/reference/newWithSpreadES5.js @@ -0,0 +1,164 @@ +//// [newWithSpreadES5.ts] + +function f(x: number, y: number, ...z: string[]) { +} + +interface A { + f: { + new (x: number, y: number, ...z: string[]); + } +} + +class B { + constructor(x: number, y: number, ...z: string[]) {} +} + +interface C { + "a-b": typeof B; +} + +interface D { + 1: typeof B; +} + +var a: string[]; +var b: A; +var c: C; +var d: A[]; +var e: { [key: string]: A }; +var g: C[]; +var h: { [key: string]: C }; +var i: C[][]; + +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); + +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); + +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); + +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); + +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); + +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); + +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); + +//// [newWithSpreadES5.js] +function f(x, y) { + var z = []; + for (var _i = 2; _i < arguments.length; _i++) { + z[_i - 2] = arguments[_i]; + } +} +var B = (function () { + function B(x, y) { + var z = []; + for (var _i = 2; _i < arguments.length; _i++) { + z[_i - 2] = arguments[_i]; + } + } + return B; +})(); +var a; +var b; +var c; +var d; +var e; +var g; +var h; +var i; +// Basic expression +new f(1, 2, "string"); +new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"])))); +// Call expression +new f(1, 2, "string")(); +new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a))))(); +new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))(); +// Property access expression +new b.f(1, 2, "string"); +new (Function.bind.apply(b.f, [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(b.f, [void 0].concat([1, 2].concat(a, ["string"])))); +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (Function.bind.apply((b.f), [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply((b.f), [void 0].concat([1, 2].concat(a, ["string"])))); +// Element access expression +new d[1].f(1, 2, "string"); +new (Function.bind.apply(d[1].f, [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(d[1].f, [void 0].concat([1, 2].concat(a, ["string"])))); +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new (Function.bind.apply(e["a-b"].f, [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(e["a-b"].f, [void 0].concat([1, 2].concat(a, ["string"])))); +// Basic expression +new B(1, 2, "string"); +new (Function.bind.apply(B, [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"])))); +// Property access expression +new c["a-b"](1, 2, "string"); +new (Function.bind.apply(c["a-b"], [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(c["a-b"], [void 0].concat([1, 2].concat(a, ["string"])))); +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (Function.bind.apply((c["a-b"]), [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply((c["a-b"]), [void 0].concat([1, 2].concat(a, ["string"])))); +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new (Function.bind.apply(g[1]["a-b"], [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(g[1]["a-b"], [void 0].concat([1, 2].concat(a, ["string"])))); +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new (Function.bind.apply(h["a-b"]["a-b"], [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(h["a-b"]["a-b"], [void 0].concat([1, 2].concat(a, ["string"])))); +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new (Function.bind.apply(i["a-b"][1], [void 0].concat([1, 2].concat(a)))); +new (Function.bind.apply(i["a-b"][1], [void 0].concat([1, 2].concat(a, ["string"])))); diff --git a/tests/baselines/reference/newWithSpreadES5.symbols b/tests/baselines/reference/newWithSpreadES5.symbols new file mode 100644 index 0000000000000..dc37c41f597dc --- /dev/null +++ b/tests/baselines/reference/newWithSpreadES5.symbols @@ -0,0 +1,258 @@ +=== tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts === + +function f(x: number, y: number, ...z: string[]) { +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) +>x : Symbol(x, Decl(newWithSpreadES5.ts, 1, 11)) +>y : Symbol(y, Decl(newWithSpreadES5.ts, 1, 21)) +>z : Symbol(z, Decl(newWithSpreadES5.ts, 1, 32)) +} + +interface A { +>A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) + + f: { +>f : Symbol(f, Decl(newWithSpreadES5.ts, 4, 13)) + + new (x: number, y: number, ...z: string[]); +>x : Symbol(x, Decl(newWithSpreadES5.ts, 6, 13)) +>y : Symbol(y, Decl(newWithSpreadES5.ts, 6, 23)) +>z : Symbol(z, Decl(newWithSpreadES5.ts, 6, 34)) + } +} + +class B { +>B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) + + constructor(x: number, y: number, ...z: string[]) {} +>x : Symbol(x, Decl(newWithSpreadES5.ts, 11, 16)) +>y : Symbol(y, Decl(newWithSpreadES5.ts, 11, 26)) +>z : Symbol(z, Decl(newWithSpreadES5.ts, 11, 37)) +} + +interface C { +>C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) + + "a-b": typeof B; +>B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +} + +interface D { +>D : Symbol(D, Decl(newWithSpreadES5.ts, 16, 1)) + + 1: typeof B; +>B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +} + +var a: string[]; +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +var b: A; +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) + +var c: C; +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) + +var d: A[]; +>d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) + +var e: { [key: string]: A }; +>e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) +>key : Symbol(key, Decl(newWithSpreadES5.ts, 26, 10)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) + +var g: C[]; +>g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) + +var h: { [key: string]: C }; +>h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) +>key : Symbol(key, Decl(newWithSpreadES5.ts, 28, 10)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) + +var i: C[][]; +>i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) + +// Basic expression +new f(1, 2, "string"); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) + +new f(1, 2, ...a); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new f(1, 2, ...a, "string"); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Call expression +new f(1, 2, "string")(); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) + +new f(1, 2, ...a)(); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new f(1, 2, ...a, "string")(); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Property access expression +new b.f(1, 2, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) + +new b.f(1, 2, ...a); +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new b.f(1, 2, ...a, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Parenthesised expression +new (b.f)(1, 2, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) + +new (b.f)(1, 2, ...a); +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new (b.f)(1, 2, ...a, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Element access expression +new d[1].f(1, 2, "string"); +>d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) + +new d[1].f(1, 2, ...a); +>d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new d[1].f(1, 2, ...a, "string"); +>d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) + +new e["a-b"].f(1, 2, ...a); +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new e["a-b"].f(1, 2, ...a, "string"); +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Basic expression +new B(1, 2, "string"); +>B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) + +new B(1, 2, ...a); +>B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new B(1, 2, ...a, "string"); +>B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Property access expression +new c["a-b"](1, 2, "string"); +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) + +new c["a-b"](1, 2, ...a); +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new c["a-b"](1, 2, ...a, "string"); +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) + +new (c["a-b"])(1, 2, ...a); +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new (c["a-b"])(1, 2, ...a, "string"); +>c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +>g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) + +new g[1]["a-b"](1, 2, ...a); +>g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new g[1]["a-b"](1, 2, ...a, "string"); +>g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +>h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) + +new h["a-b"]["a-b"](1, 2, ...a); +>h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new h["a-b"]["a-b"](1, 2, ...a, "string"); +>h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +>i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) + +new i["a-b"][1](1, 2, ...a); +>i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + +new i["a-b"][1](1, 2, ...a, "string"); +>i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) + diff --git a/tests/baselines/reference/newWithSpreadES5.types b/tests/baselines/reference/newWithSpreadES5.types new file mode 100644 index 0000000000000..9948d075befed --- /dev/null +++ b/tests/baselines/reference/newWithSpreadES5.types @@ -0,0 +1,471 @@ +=== tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts === + +function f(x: number, y: number, ...z: string[]) { +>f : (x: number, y: number, ...z: string[]) => void +>x : number +>y : number +>z : string[] +} + +interface A { +>A : A + + f: { +>f : new (x: number, y: number, ...z: string[]) => any + + new (x: number, y: number, ...z: string[]); +>x : number +>y : number +>z : string[] + } +} + +class B { +>B : B + + constructor(x: number, y: number, ...z: string[]) {} +>x : number +>y : number +>z : string[] +} + +interface C { +>C : C + + "a-b": typeof B; +>B : typeof B +} + +interface D { +>D : D + + 1: typeof B; +>B : typeof B +} + +var a: string[]; +>a : string[] + +var b: A; +>b : A +>A : A + +var c: C; +>c : C +>C : C + +var d: A[]; +>d : A[] +>A : A + +var e: { [key: string]: A }; +>e : { [key: string]: A; } +>key : string +>A : A + +var g: C[]; +>g : C[] +>C : C + +var h: { [key: string]: C }; +>h : { [key: string]: C; } +>key : string +>C : C + +var i: C[][]; +>i : C[][] +>C : C + +// Basic expression +new f(1, 2, "string"); +>new f(1, 2, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>"string" : string + +new f(1, 2, ...a); +>new f(1, 2, ...a) : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] + +new f(1, 2, ...a, "string"); +>new f(1, 2, ...a, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Call expression +new f(1, 2, "string")(); +>new f(1, 2, "string")() : any +>new f(1, 2, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>"string" : string + +new f(1, 2, ...a)(); +>new f(1, 2, ...a)() : any +>new f(1, 2, ...a) : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] + +new f(1, 2, ...a, "string")(); +>new f(1, 2, ...a, "string")() : any +>new f(1, 2, ...a, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Property access expression +new b.f(1, 2, "string"); +>new b.f(1, 2, "string") : any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new b.f(1, 2, ...a); +>new b.f(1, 2, ...a) : any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new b.f(1, 2, ...a, "string"); +>new b.f(1, 2, ...a, "string") : any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Parenthesised expression +new (b.f)(1, 2, "string"); +>new (b.f)(1, 2, "string") : any +>(b.f) : new (x: number, y: number, ...z: string[]) => any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new (b.f)(1, 2, ...a); +>new (b.f)(1, 2, ...a) : any +>(b.f) : new (x: number, y: number, ...z: string[]) => any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new (b.f)(1, 2, ...a, "string"); +>new (b.f)(1, 2, ...a, "string") : any +>(b.f) : new (x: number, y: number, ...z: string[]) => any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression +new d[1].f(1, 2, "string"); +>new d[1].f(1, 2, "string") : any +>d[1].f : new (x: number, y: number, ...z: string[]) => any +>d[1] : A +>d : A[] +>1 : number +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new d[1].f(1, 2, ...a); +>new d[1].f(1, 2, ...a) : any +>d[1].f : new (x: number, y: number, ...z: string[]) => any +>d[1] : A +>d : A[] +>1 : number +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new d[1].f(1, 2, ...a, "string"); +>new d[1].f(1, 2, ...a, "string") : any +>d[1].f : new (x: number, y: number, ...z: string[]) => any +>d[1] : A +>d : A[] +>1 : number +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +>new e["a-b"].f(1, 2, "string") : any +>e["a-b"].f : new (x: number, y: number, ...z: string[]) => any +>e["a-b"] : A +>e : { [key: string]: A; } +>"a-b" : string +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new e["a-b"].f(1, 2, ...a); +>new e["a-b"].f(1, 2, ...a) : any +>e["a-b"].f : new (x: number, y: number, ...z: string[]) => any +>e["a-b"] : A +>e : { [key: string]: A; } +>"a-b" : string +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new e["a-b"].f(1, 2, ...a, "string"); +>new e["a-b"].f(1, 2, ...a, "string") : any +>e["a-b"].f : new (x: number, y: number, ...z: string[]) => any +>e["a-b"] : A +>e : { [key: string]: A; } +>"a-b" : string +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Basic expression +new B(1, 2, "string"); +>new B(1, 2, "string") : B +>B : typeof B +>1 : number +>2 : number +>"string" : string + +new B(1, 2, ...a); +>new B(1, 2, ...a) : B +>B : typeof B +>1 : number +>2 : number +>...a : string +>a : string[] + +new B(1, 2, ...a, "string"); +>new B(1, 2, ...a, "string") : B +>B : typeof B +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Property access expression +new c["a-b"](1, 2, "string"); +>new c["a-b"](1, 2, "string") : B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new c["a-b"](1, 2, ...a); +>new c["a-b"](1, 2, ...a) : B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new c["a-b"](1, 2, ...a, "string"); +>new c["a-b"](1, 2, ...a, "string") : B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +>new (c["a-b"])(1, 2, "string") : B +>(c["a-b"]) : typeof B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new (c["a-b"])(1, 2, ...a); +>new (c["a-b"])(1, 2, ...a) : B +>(c["a-b"]) : typeof B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new (c["a-b"])(1, 2, ...a, "string"); +>new (c["a-b"])(1, 2, ...a, "string") : B +>(c["a-b"]) : typeof B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +>new g[1]["a-b"](1, 2, "string") : B +>g[1]["a-b"] : typeof B +>g[1] : C +>g : C[] +>1 : number +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new g[1]["a-b"](1, 2, ...a); +>new g[1]["a-b"](1, 2, ...a) : B +>g[1]["a-b"] : typeof B +>g[1] : C +>g : C[] +>1 : number +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new g[1]["a-b"](1, 2, ...a, "string"); +>new g[1]["a-b"](1, 2, ...a, "string") : B +>g[1]["a-b"] : typeof B +>g[1] : C +>g : C[] +>1 : number +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +>new h["a-b"]["a-b"](1, 2, "string") : B +>h["a-b"]["a-b"] : typeof B +>h["a-b"] : C +>h : { [key: string]: C; } +>"a-b" : string +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new h["a-b"]["a-b"](1, 2, ...a); +>new h["a-b"]["a-b"](1, 2, ...a) : B +>h["a-b"]["a-b"] : typeof B +>h["a-b"] : C +>h : { [key: string]: C; } +>"a-b" : string +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new h["a-b"]["a-b"](1, 2, ...a, "string"); +>new h["a-b"]["a-b"](1, 2, ...a, "string") : B +>h["a-b"]["a-b"] : typeof B +>h["a-b"] : C +>h : { [key: string]: C; } +>"a-b" : string +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +>new i["a-b"][1](1, 2, "string") : any +>i["a-b"][1] : any +>i["a-b"] : any +>i : C[][] +>"a-b" : string +>1 : number +>1 : number +>2 : number +>"string" : string + +new i["a-b"][1](1, 2, ...a); +>new i["a-b"][1](1, 2, ...a) : any +>i["a-b"][1] : any +>i["a-b"] : any +>i : C[][] +>"a-b" : string +>1 : number +>1 : number +>2 : number +>...a : string +>a : string[] + +new i["a-b"][1](1, 2, ...a, "string"); +>new i["a-b"][1](1, 2, ...a, "string") : any +>i["a-b"][1] : any +>i["a-b"] : any +>i : C[][] +>"a-b" : string +>1 : number +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + diff --git a/tests/baselines/reference/newWithSpreadES6.js b/tests/baselines/reference/newWithSpreadES6.js new file mode 100644 index 0000000000000..dae7c9229db80 --- /dev/null +++ b/tests/baselines/reference/newWithSpreadES6.js @@ -0,0 +1,155 @@ +//// [newWithSpreadES6.ts] + +function f(x: number, y: number, ...z: string[]) { +} + +interface A { + f: { + new (x: number, y: number, ...z: string[]); + } +} + +class B { + constructor(x: number, y: number, ...z: string[]) {} +} + +interface C { + "a-b": typeof B; +} + +interface D { + 1: typeof B; +} + +var a: string[]; +var b: A; +var c: C; +var d: A[]; +var e: { [key: string]: A }; +var g: C[]; +var h: { [key: string]: C }; +var i: C[][]; + +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); + +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); + +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); + +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); + +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); + +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); + +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); + +//// [newWithSpreadES6.js] +function f(x, y, ...z) { +} +class B { + constructor(x, y, ...z) { + } +} +var a; +var b; +var c; +var d; +var e; +var g; +var h; +var i; +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); diff --git a/tests/baselines/reference/newWithSpreadES6.symbols b/tests/baselines/reference/newWithSpreadES6.symbols new file mode 100644 index 0000000000000..f16984fb4815a --- /dev/null +++ b/tests/baselines/reference/newWithSpreadES6.symbols @@ -0,0 +1,258 @@ +=== tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts === + +function f(x: number, y: number, ...z: string[]) { +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) +>x : Symbol(x, Decl(newWithSpreadES6.ts, 1, 11)) +>y : Symbol(y, Decl(newWithSpreadES6.ts, 1, 21)) +>z : Symbol(z, Decl(newWithSpreadES6.ts, 1, 32)) +} + +interface A { +>A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) + + f: { +>f : Symbol(f, Decl(newWithSpreadES6.ts, 4, 13)) + + new (x: number, y: number, ...z: string[]); +>x : Symbol(x, Decl(newWithSpreadES6.ts, 6, 13)) +>y : Symbol(y, Decl(newWithSpreadES6.ts, 6, 23)) +>z : Symbol(z, Decl(newWithSpreadES6.ts, 6, 34)) + } +} + +class B { +>B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) + + constructor(x: number, y: number, ...z: string[]) {} +>x : Symbol(x, Decl(newWithSpreadES6.ts, 11, 16)) +>y : Symbol(y, Decl(newWithSpreadES6.ts, 11, 26)) +>z : Symbol(z, Decl(newWithSpreadES6.ts, 11, 37)) +} + +interface C { +>C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) + + "a-b": typeof B; +>B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +} + +interface D { +>D : Symbol(D, Decl(newWithSpreadES6.ts, 16, 1)) + + 1: typeof B; +>B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +} + +var a: string[]; +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +var b: A; +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) + +var c: C; +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) + +var d: A[]; +>d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) + +var e: { [key: string]: A }; +>e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) +>key : Symbol(key, Decl(newWithSpreadES6.ts, 26, 10)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) + +var g: C[]; +>g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) + +var h: { [key: string]: C }; +>h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) +>key : Symbol(key, Decl(newWithSpreadES6.ts, 28, 10)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) + +var i: C[][]; +>i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) + +// Basic expression +new f(1, 2, "string"); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) + +new f(1, 2, ...a); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new f(1, 2, ...a, "string"); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Call expression +new f(1, 2, "string")(); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) + +new f(1, 2, ...a)(); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new f(1, 2, ...a, "string")(); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Property access expression +new b.f(1, 2, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) + +new b.f(1, 2, ...a); +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new b.f(1, 2, ...a, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Parenthesised expression +new (b.f)(1, 2, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) + +new (b.f)(1, 2, ...a); +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new (b.f)(1, 2, ...a, "string"); +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Element access expression +new d[1].f(1, 2, "string"); +>d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) + +new d[1].f(1, 2, ...a); +>d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new d[1].f(1, 2, ...a, "string"); +>d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) + +new e["a-b"].f(1, 2, ...a); +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new e["a-b"].f(1, 2, ...a, "string"); +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Basic expression +new B(1, 2, "string"); +>B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) + +new B(1, 2, ...a); +>B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new B(1, 2, ...a, "string"); +>B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Property access expression +new c["a-b"](1, 2, "string"); +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) + +new c["a-b"](1, 2, ...a); +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new c["a-b"](1, 2, ...a, "string"); +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) + +new (c["a-b"])(1, 2, ...a); +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new (c["a-b"])(1, 2, ...a, "string"); +>c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +>g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) + +new g[1]["a-b"](1, 2, ...a); +>g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new g[1]["a-b"](1, 2, ...a, "string"); +>g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +>h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) + +new h["a-b"]["a-b"](1, 2, ...a); +>h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new h["a-b"]["a-b"](1, 2, ...a, "string"); +>h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +>i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) + +new i["a-b"][1](1, 2, ...a); +>i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + +new i["a-b"][1](1, 2, ...a, "string"); +>i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) + diff --git a/tests/baselines/reference/newWithSpreadES6.types b/tests/baselines/reference/newWithSpreadES6.types new file mode 100644 index 0000000000000..7be42103419d0 --- /dev/null +++ b/tests/baselines/reference/newWithSpreadES6.types @@ -0,0 +1,471 @@ +=== tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts === + +function f(x: number, y: number, ...z: string[]) { +>f : (x: number, y: number, ...z: string[]) => void +>x : number +>y : number +>z : string[] +} + +interface A { +>A : A + + f: { +>f : new (x: number, y: number, ...z: string[]) => any + + new (x: number, y: number, ...z: string[]); +>x : number +>y : number +>z : string[] + } +} + +class B { +>B : B + + constructor(x: number, y: number, ...z: string[]) {} +>x : number +>y : number +>z : string[] +} + +interface C { +>C : C + + "a-b": typeof B; +>B : typeof B +} + +interface D { +>D : D + + 1: typeof B; +>B : typeof B +} + +var a: string[]; +>a : string[] + +var b: A; +>b : A +>A : A + +var c: C; +>c : C +>C : C + +var d: A[]; +>d : A[] +>A : A + +var e: { [key: string]: A }; +>e : { [key: string]: A; } +>key : string +>A : A + +var g: C[]; +>g : C[] +>C : C + +var h: { [key: string]: C }; +>h : { [key: string]: C; } +>key : string +>C : C + +var i: C[][]; +>i : C[][] +>C : C + +// Basic expression +new f(1, 2, "string"); +>new f(1, 2, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>"string" : string + +new f(1, 2, ...a); +>new f(1, 2, ...a) : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] + +new f(1, 2, ...a, "string"); +>new f(1, 2, ...a, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Call expression +new f(1, 2, "string")(); +>new f(1, 2, "string")() : any +>new f(1, 2, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>"string" : string + +new f(1, 2, ...a)(); +>new f(1, 2, ...a)() : any +>new f(1, 2, ...a) : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] + +new f(1, 2, ...a, "string")(); +>new f(1, 2, ...a, "string")() : any +>new f(1, 2, ...a, "string") : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Property access expression +new b.f(1, 2, "string"); +>new b.f(1, 2, "string") : any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new b.f(1, 2, ...a); +>new b.f(1, 2, ...a) : any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new b.f(1, 2, ...a, "string"); +>new b.f(1, 2, ...a, "string") : any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Parenthesised expression +new (b.f)(1, 2, "string"); +>new (b.f)(1, 2, "string") : any +>(b.f) : new (x: number, y: number, ...z: string[]) => any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new (b.f)(1, 2, ...a); +>new (b.f)(1, 2, ...a) : any +>(b.f) : new (x: number, y: number, ...z: string[]) => any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new (b.f)(1, 2, ...a, "string"); +>new (b.f)(1, 2, ...a, "string") : any +>(b.f) : new (x: number, y: number, ...z: string[]) => any +>b.f : new (x: number, y: number, ...z: string[]) => any +>b : A +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression +new d[1].f(1, 2, "string"); +>new d[1].f(1, 2, "string") : any +>d[1].f : new (x: number, y: number, ...z: string[]) => any +>d[1] : A +>d : A[] +>1 : number +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new d[1].f(1, 2, ...a); +>new d[1].f(1, 2, ...a) : any +>d[1].f : new (x: number, y: number, ...z: string[]) => any +>d[1] : A +>d : A[] +>1 : number +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new d[1].f(1, 2, ...a, "string"); +>new d[1].f(1, 2, ...a, "string") : any +>d[1].f : new (x: number, y: number, ...z: string[]) => any +>d[1] : A +>d : A[] +>1 : number +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +>new e["a-b"].f(1, 2, "string") : any +>e["a-b"].f : new (x: number, y: number, ...z: string[]) => any +>e["a-b"] : A +>e : { [key: string]: A; } +>"a-b" : string +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"string" : string + +new e["a-b"].f(1, 2, ...a); +>new e["a-b"].f(1, 2, ...a) : any +>e["a-b"].f : new (x: number, y: number, ...z: string[]) => any +>e["a-b"] : A +>e : { [key: string]: A; } +>"a-b" : string +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +new e["a-b"].f(1, 2, ...a, "string"); +>new e["a-b"].f(1, 2, ...a, "string") : any +>e["a-b"].f : new (x: number, y: number, ...z: string[]) => any +>e["a-b"] : A +>e : { [key: string]: A; } +>"a-b" : string +>f : new (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Basic expression +new B(1, 2, "string"); +>new B(1, 2, "string") : B +>B : typeof B +>1 : number +>2 : number +>"string" : string + +new B(1, 2, ...a); +>new B(1, 2, ...a) : B +>B : typeof B +>1 : number +>2 : number +>...a : string +>a : string[] + +new B(1, 2, ...a, "string"); +>new B(1, 2, ...a, "string") : B +>B : typeof B +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Property access expression +new c["a-b"](1, 2, "string"); +>new c["a-b"](1, 2, "string") : B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new c["a-b"](1, 2, ...a); +>new c["a-b"](1, 2, ...a) : B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new c["a-b"](1, 2, ...a, "string"); +>new c["a-b"](1, 2, ...a, "string") : B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +>new (c["a-b"])(1, 2, "string") : B +>(c["a-b"]) : typeof B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new (c["a-b"])(1, 2, ...a); +>new (c["a-b"])(1, 2, ...a) : B +>(c["a-b"]) : typeof B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new (c["a-b"])(1, 2, ...a, "string"); +>new (c["a-b"])(1, 2, ...a, "string") : B +>(c["a-b"]) : typeof B +>c["a-b"] : typeof B +>c : C +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +>new g[1]["a-b"](1, 2, "string") : B +>g[1]["a-b"] : typeof B +>g[1] : C +>g : C[] +>1 : number +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new g[1]["a-b"](1, 2, ...a); +>new g[1]["a-b"](1, 2, ...a) : B +>g[1]["a-b"] : typeof B +>g[1] : C +>g : C[] +>1 : number +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new g[1]["a-b"](1, 2, ...a, "string"); +>new g[1]["a-b"](1, 2, ...a, "string") : B +>g[1]["a-b"] : typeof B +>g[1] : C +>g : C[] +>1 : number +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +>new h["a-b"]["a-b"](1, 2, "string") : B +>h["a-b"]["a-b"] : typeof B +>h["a-b"] : C +>h : { [key: string]: C; } +>"a-b" : string +>"a-b" : string +>1 : number +>2 : number +>"string" : string + +new h["a-b"]["a-b"](1, 2, ...a); +>new h["a-b"]["a-b"](1, 2, ...a) : B +>h["a-b"]["a-b"] : typeof B +>h["a-b"] : C +>h : { [key: string]: C; } +>"a-b" : string +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] + +new h["a-b"]["a-b"](1, 2, ...a, "string"); +>new h["a-b"]["a-b"](1, 2, ...a, "string") : B +>h["a-b"]["a-b"] : typeof B +>h["a-b"] : C +>h : { [key: string]: C; } +>"a-b" : string +>"a-b" : string +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +>new i["a-b"][1](1, 2, "string") : any +>i["a-b"][1] : any +>i["a-b"] : any +>i : C[][] +>"a-b" : string +>1 : number +>1 : number +>2 : number +>"string" : string + +new i["a-b"][1](1, 2, ...a); +>new i["a-b"][1](1, 2, ...a) : any +>i["a-b"][1] : any +>i["a-b"] : any +>i : C[][] +>"a-b" : string +>1 : number +>1 : number +>2 : number +>...a : string +>a : string[] + +new i["a-b"][1](1, 2, ...a, "string"); +>new i["a-b"][1](1, 2, ...a, "string") : any +>i["a-b"][1] : any +>i["a-b"] : any +>i : C[][] +>"a-b" : string +>1 : number +>1 : number +>2 : number +>...a : string +>a : string[] +>"string" : string + diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts new file mode 100644 index 0000000000000..6550658c81401 --- /dev/null +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts @@ -0,0 +1,90 @@ + +function f(x: number, y: number, ...z: string[]) { +} + +interface A { + f: { + new (x: number, y: number, ...z: string[]); + } +} + +class B { + constructor(x: number, y: number, ...z: string[]) {} +} + +interface C { + "a-b": typeof B; +} + +interface D { + 1: typeof B; +} + +var a: string[]; +var b: A; +var c: C; +var d: A[]; +var e: { [key: string]: A }; +var g: C[]; +var h: { [key: string]: C }; +var i: C[][]; + +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); + +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); + +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); + +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); + +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); + +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); + +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts new file mode 100644 index 0000000000000..0a60c6ff3394f --- /dev/null +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts @@ -0,0 +1,91 @@ +//@target: ES5 + +function f(x: number, y: number, ...z: string[]) { +} + +interface A { + f: { + new (x: number, y: number, ...z: string[]); + } +} + +class B { + constructor(x: number, y: number, ...z: string[]) {} +} + +interface C { + "a-b": typeof B; +} + +interface D { + 1: typeof B; +} + +var a: string[]; +var b: A; +var c: C; +var d: A[]; +var e: { [key: string]: A }; +var g: C[]; +var h: { [key: string]: C }; +var i: C[][]; + +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); + +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); + +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); + +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); + +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); + +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); + +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts new file mode 100644 index 0000000000000..ec235f7a6199e --- /dev/null +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts @@ -0,0 +1,91 @@ +//@target: ES6 + +function f(x: number, y: number, ...z: string[]) { +} + +interface A { + f: { + new (x: number, y: number, ...z: string[]); + } +} + +class B { + constructor(x: number, y: number, ...z: string[]) {} +} + +interface C { + "a-b": typeof B; +} + +interface D { + 1: typeof B; +} + +var a: string[]; +var b: A; +var c: C; +var d: A[]; +var e: { [key: string]: A }; +var g: C[]; +var h: { [key: string]: C }; +var i: C[][]; + +// Basic expression +new f(1, 2, "string"); +new f(1, 2, ...a); +new f(1, 2, ...a, "string"); + +// Call expression +new f(1, 2, "string")(); +new f(1, 2, ...a)(); +new f(1, 2, ...a, "string")(); + +// Property access expression +new b.f(1, 2, "string"); +new b.f(1, 2, ...a); +new b.f(1, 2, ...a, "string"); + +// Parenthesised expression +new (b.f)(1, 2, "string"); +new (b.f)(1, 2, ...a); +new (b.f)(1, 2, ...a, "string"); + +// Element access expression +new d[1].f(1, 2, "string"); +new d[1].f(1, 2, ...a); +new d[1].f(1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new e["a-b"].f(1, 2, "string"); +new e["a-b"].f(1, 2, ...a); +new e["a-b"].f(1, 2, ...a, "string"); + +// Basic expression +new B(1, 2, "string"); +new B(1, 2, ...a); +new B(1, 2, ...a, "string"); + +// Property access expression +new c["a-b"](1, 2, "string"); +new c["a-b"](1, 2, ...a); +new c["a-b"](1, 2, ...a, "string"); + +// Parenthesised expression +new (c["a-b"])(1, 2, "string"); +new (c["a-b"])(1, 2, ...a); +new (c["a-b"])(1, 2, ...a, "string"); + +// Element access expression +new g[1]["a-b"](1, 2, "string"); +new g[1]["a-b"](1, 2, ...a); +new g[1]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a punctuated key +new h["a-b"]["a-b"](1, 2, "string"); +new h["a-b"]["a-b"](1, 2, ...a); +new h["a-b"]["a-b"](1, 2, ...a, "string"); + +// Element access expression with a number +new i["a-b"][1](1, 2, "string"); +new i["a-b"][1](1, 2, ...a); +new i["a-b"][1](1, 2, ...a, "string"); \ No newline at end of file From d13081685b0b471cbec7aa31e8b06b38f7f6ef61 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Wed, 13 May 2015 09:36:40 +0800 Subject: [PATCH 03/11] Adds spread syntax in new expression in ES5 --- src/compiler/checker.ts | 8 ++-- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/emitter.ts | 39 +++++++++++++++++-- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3201434da5839..020226439b720 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6599,7 +6599,7 @@ module ts { result.splice(spliceIndex, 0, signature); } } - + function getSpreadArgumentIndex(args: Expression[]): number { for (let i = 0; i < args.length; i++) { if (args[i].kind === SyntaxKind.SpreadElementExpression) { @@ -7121,10 +7121,10 @@ module ts { } function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature { - if (node.arguments && languageVersion < ScriptTarget.ES6) { + if (node.arguments && languageVersion < ScriptTarget.ES5) { let spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { - error(node.arguments[spreadIndex], Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher); + error(node.arguments[spreadIndex], Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); } } @@ -7142,7 +7142,7 @@ module ts { // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate - // signatures for overload resolution.The result type of the function call becomes + // signatures for overload resolution. The result type of the function call becomes // the result type of the operation. expressionType = getApparentType(expressionType); if (expressionType === unknownType) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 32dc590eeecff..2a8527168464a 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -334,7 +334,7 @@ module ts { The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." }, Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." }, A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." }, - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." }, + Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." }, Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." }, const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a3dfd62d34e75..cf1645b140724 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1324,7 +1324,7 @@ "category": "Error", "code": 2471 }, - "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.": { + "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher.": { "category": "Error", "code": 2472 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index c9d23ec5ceebf..8f33cc151e7d5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1886,11 +1886,42 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { function emitNewExpression(node: NewExpression) { write("new "); - emit(node.expression); - if (node.arguments) { + + // Spread operator logic can be supported in new expressions in ES5 using a combination + // of Function.prototype.bind() and Function.prototype.apply(). + // + // Example: + // + // var arguments = [1, 2, 3, 4, 5]; + // new Array(...arguments); + // + // Could be transpiled into ES5: + // + // var arguments = [1, 2, 3, 4, 5]; + // new (Function.bind.apply(Array, [void 0].concat(arguments))); + // + // `[void 0]` is the first argument which represents `thisArg` to the bind method above. + // And `thisArg` will be set to the return value of the constructor when instantiated + // with the new operator — regardless of any value we set `thisArg` to. Thus, we set it + // to an undefined, `void 0`. + if (languageVersion === ScriptTarget.ES5 && + node.arguments && + hasSpreadElement(node.arguments)) { + write("("); - emitCommaList(node.arguments); - write(")"); + write("Function.bind.apply("); + emit(node.expression); + write(", [void 0].concat("); + emitListWithSpread(node.arguments, /*multiline*/false, /*trailingComma*/false); + write(")))"); + } + else { + emit(node.expression); + if (node.arguments) { + write("("); + emitCommaList(node.arguments); + write(")"); + } } } From a97ea4b6570d24f90ddf3fcaf1116140c3533b4a Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Wed, 13 May 2015 09:53:34 +0800 Subject: [PATCH 04/11] Corrects old tests. --- .../reference/callWithSpread.errors.txt | 59 ----- tests/baselines/reference/callWithSpread.js | 5 - .../reference/callWithSpread.symbols | 159 +++++++++++ .../baselines/reference/callWithSpread.types | 247 ++++++++++++++++++ .../baselines/reference/callWithSpreadES6.js | 5 - .../reference/callWithSpreadES6.symbols | 6 - .../reference/callWithSpreadES6.types | 10 - tests/baselines/reference/newWithSpreadES5.js | 49 ++-- .../functionCalls/callWithSpread.ts | 3 - .../functionCalls/callWithSpreadES6.ts | 3 - 10 files changed, 431 insertions(+), 115 deletions(-) delete mode 100644 tests/baselines/reference/callWithSpread.errors.txt create mode 100644 tests/baselines/reference/callWithSpread.symbols create mode 100644 tests/baselines/reference/callWithSpread.types diff --git a/tests/baselines/reference/callWithSpread.errors.txt b/tests/baselines/reference/callWithSpread.errors.txt deleted file mode 100644 index a28d4c8b1a176..0000000000000 --- a/tests/baselines/reference/callWithSpread.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread.ts(52,21): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher. - - -==== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts (1 errors) ==== - interface X { - foo(x: number, y: number, ...z: string[]); - } - - function foo(x: number, y: number, ...z: string[]) { - } - - var a: string[]; - var z: number[]; - var obj: X; - var xa: X[]; - - foo(1, 2, "abc"); - foo(1, 2, ...a); - foo(1, 2, ...a, "abc"); - - obj.foo(1, 2, "abc"); - obj.foo(1, 2, ...a); - obj.foo(1, 2, ...a, "abc"); - - (obj.foo)(1, 2, "abc"); - (obj.foo)(1, 2, ...a); - (obj.foo)(1, 2, ...a, "abc"); - - xa[1].foo(1, 2, "abc"); - xa[1].foo(1, 2, ...a); - xa[1].foo(1, 2, ...a, "abc"); - - (xa[1].foo)(...[1, 2, "abc"]); - - class C { - constructor(x: number, y: number, ...z: string[]) { - this.foo(x, y); - this.foo(x, y, ...z); - } - foo(x: number, y: number, ...z: string[]) { - } - } - - class D extends C { - constructor() { - super(1, 2); - super(1, 2, ...a); - } - foo() { - super.foo(1, 2); - super.foo(1, 2, ...a); - } - } - - // Only supported in when target is ES6 - var c = new C(1, 2, ...a); - ~~~~ -!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher. - \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index c9cd5d2adce65..d21b4879daabf 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -48,9 +48,6 @@ class D extends C { super.foo(1, 2, ...a); } } - -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); //// [callWithSpread.js] @@ -112,6 +109,4 @@ var D = (function (_super) { }; return D; })(C); -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); var _a, _b, _c; diff --git a/tests/baselines/reference/callWithSpread.symbols b/tests/baselines/reference/callWithSpread.symbols new file mode 100644 index 0000000000000..c5ac7fe66b2f9 --- /dev/null +++ b/tests/baselines/reference/callWithSpread.symbols @@ -0,0 +1,159 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts === +interface X { +>X : Symbol(X, Decl(callWithSpread.ts, 0, 0)) + + foo(x: number, y: number, ...z: string[]); +>foo : Symbol(foo, Decl(callWithSpread.ts, 0, 13)) +>x : Symbol(x, Decl(callWithSpread.ts, 1, 8)) +>y : Symbol(y, Decl(callWithSpread.ts, 1, 18)) +>z : Symbol(z, Decl(callWithSpread.ts, 1, 29)) +} + +function foo(x: number, y: number, ...z: string[]) { +>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1)) +>x : Symbol(x, Decl(callWithSpread.ts, 4, 13)) +>y : Symbol(y, Decl(callWithSpread.ts, 4, 23)) +>z : Symbol(z, Decl(callWithSpread.ts, 4, 34)) +} + +var a: string[]; +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +var z: number[]; +>z : Symbol(z, Decl(callWithSpread.ts, 8, 3)) + +var obj: X; +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>X : Symbol(X, Decl(callWithSpread.ts, 0, 0)) + +var xa: X[]; +>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3)) +>X : Symbol(X, Decl(callWithSpread.ts, 0, 0)) + +foo(1, 2, "abc"); +>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1)) + +foo(1, 2, ...a); +>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +foo(1, 2, ...a, "abc"); +>foo : Symbol(foo, Decl(callWithSpread.ts, 2, 1)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +obj.foo(1, 2, "abc"); +>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) + +obj.foo(1, 2, ...a); +>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +obj.foo(1, 2, ...a, "abc"); +>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +(obj.foo)(1, 2, "abc"); +>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) + +(obj.foo)(1, 2, ...a); +>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +(obj.foo)(1, 2, ...a, "abc"); +>obj.foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>obj : Symbol(obj, Decl(callWithSpread.ts, 9, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +xa[1].foo(1, 2, "abc"); +>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) + +xa[1].foo(1, 2, ...a); +>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +xa[1].foo(1, 2, ...a, "abc"); +>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + +(xa[1].foo)(...[1, 2, "abc"]); +>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11)) +>xa[1].foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) +>xa : Symbol(xa, Decl(callWithSpread.ts, 10, 3)) +>foo : Symbol(X.foo, Decl(callWithSpread.ts, 0, 13)) + +class C { +>C : Symbol(C, Decl(callWithSpread.ts, 28, 40)) + + constructor(x: number, y: number, ...z: string[]) { +>x : Symbol(x, Decl(callWithSpread.ts, 31, 16)) +>y : Symbol(y, Decl(callWithSpread.ts, 31, 26)) +>z : Symbol(z, Decl(callWithSpread.ts, 31, 37)) + + this.foo(x, y); +>this.foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5)) +>this : Symbol(C, Decl(callWithSpread.ts, 28, 40)) +>foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5)) +>x : Symbol(x, Decl(callWithSpread.ts, 31, 16)) +>y : Symbol(y, Decl(callWithSpread.ts, 31, 26)) + + this.foo(x, y, ...z); +>this.foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5)) +>this : Symbol(C, Decl(callWithSpread.ts, 28, 40)) +>foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5)) +>x : Symbol(x, Decl(callWithSpread.ts, 31, 16)) +>y : Symbol(y, Decl(callWithSpread.ts, 31, 26)) +>z : Symbol(z, Decl(callWithSpread.ts, 31, 37)) + } + foo(x: number, y: number, ...z: string[]) { +>foo : Symbol(foo, Decl(callWithSpread.ts, 34, 5)) +>x : Symbol(x, Decl(callWithSpread.ts, 35, 8)) +>y : Symbol(y, Decl(callWithSpread.ts, 35, 18)) +>z : Symbol(z, Decl(callWithSpread.ts, 35, 29)) + } +} + +class D extends C { +>D : Symbol(D, Decl(callWithSpread.ts, 37, 1)) +>C : Symbol(C, Decl(callWithSpread.ts, 28, 40)) + + constructor() { + super(1, 2); +>super : Symbol(C, Decl(callWithSpread.ts, 28, 40)) + + super(1, 2, ...a); +>super : Symbol(C, Decl(callWithSpread.ts, 28, 40)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + } + foo() { +>foo : Symbol(foo, Decl(callWithSpread.ts, 43, 5)) + + super.foo(1, 2); +>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5)) +>super : Symbol(C, Decl(callWithSpread.ts, 28, 40)) +>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5)) + + super.foo(1, 2, ...a); +>super.foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5)) +>super : Symbol(C, Decl(callWithSpread.ts, 28, 40)) +>foo : Symbol(C.foo, Decl(callWithSpread.ts, 34, 5)) +>a : Symbol(a, Decl(callWithSpread.ts, 7, 3)) + } +} + diff --git a/tests/baselines/reference/callWithSpread.types b/tests/baselines/reference/callWithSpread.types new file mode 100644 index 0000000000000..f7097727204ff --- /dev/null +++ b/tests/baselines/reference/callWithSpread.types @@ -0,0 +1,247 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts === +interface X { +>X : X + + foo(x: number, y: number, ...z: string[]); +>foo : (x: number, y: number, ...z: string[]) => any +>x : number +>y : number +>z : string[] +} + +function foo(x: number, y: number, ...z: string[]) { +>foo : (x: number, y: number, ...z: string[]) => void +>x : number +>y : number +>z : string[] +} + +var a: string[]; +>a : string[] + +var z: number[]; +>z : number[] + +var obj: X; +>obj : X +>X : X + +var xa: X[]; +>xa : X[] +>X : X + +foo(1, 2, "abc"); +>foo(1, 2, "abc") : void +>foo : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>"abc" : string + +foo(1, 2, ...a); +>foo(1, 2, ...a) : void +>foo : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] + +foo(1, 2, ...a, "abc"); +>foo(1, 2, ...a, "abc") : void +>foo : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>"abc" : string + +obj.foo(1, 2, "abc"); +>obj.foo(1, 2, "abc") : any +>obj.foo : (x: number, y: number, ...z: string[]) => any +>obj : X +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"abc" : string + +obj.foo(1, 2, ...a); +>obj.foo(1, 2, ...a) : any +>obj.foo : (x: number, y: number, ...z: string[]) => any +>obj : X +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +obj.foo(1, 2, ...a, "abc"); +>obj.foo(1, 2, ...a, "abc") : any +>obj.foo : (x: number, y: number, ...z: string[]) => any +>obj : X +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"abc" : string + +(obj.foo)(1, 2, "abc"); +>(obj.foo)(1, 2, "abc") : any +>(obj.foo) : (x: number, y: number, ...z: string[]) => any +>obj.foo : (x: number, y: number, ...z: string[]) => any +>obj : X +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"abc" : string + +(obj.foo)(1, 2, ...a); +>(obj.foo)(1, 2, ...a) : any +>(obj.foo) : (x: number, y: number, ...z: string[]) => any +>obj.foo : (x: number, y: number, ...z: string[]) => any +>obj : X +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +(obj.foo)(1, 2, ...a, "abc"); +>(obj.foo)(1, 2, ...a, "abc") : any +>(obj.foo) : (x: number, y: number, ...z: string[]) => any +>obj.foo : (x: number, y: number, ...z: string[]) => any +>obj : X +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"abc" : string + +xa[1].foo(1, 2, "abc"); +>xa[1].foo(1, 2, "abc") : any +>xa[1].foo : (x: number, y: number, ...z: string[]) => any +>xa[1] : X +>xa : X[] +>1 : number +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>"abc" : string + +xa[1].foo(1, 2, ...a); +>xa[1].foo(1, 2, ...a) : any +>xa[1].foo : (x: number, y: number, ...z: string[]) => any +>xa[1] : X +>xa : X[] +>1 : number +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] + +xa[1].foo(1, 2, ...a, "abc"); +>xa[1].foo(1, 2, ...a, "abc") : any +>xa[1].foo : (x: number, y: number, ...z: string[]) => any +>xa[1] : X +>xa : X[] +>1 : number +>foo : (x: number, y: number, ...z: string[]) => any +>1 : number +>2 : number +>...a : string +>a : string[] +>"abc" : string + +(xa[1].foo)(...[1, 2, "abc"]); +>(xa[1].foo)(...[1, 2, "abc"]) : any +>(xa[1].foo) : Function +>xa[1].foo : Function +>Function : Function +>xa[1].foo : (x: number, y: number, ...z: string[]) => any +>xa[1] : X +>xa : X[] +>1 : number +>foo : (x: number, y: number, ...z: string[]) => any +>...[1, 2, "abc"] : string | number +>[1, 2, "abc"] : (string | number)[] +>1 : number +>2 : number +>"abc" : string + +class C { +>C : C + + constructor(x: number, y: number, ...z: string[]) { +>x : number +>y : number +>z : string[] + + this.foo(x, y); +>this.foo(x, y) : void +>this.foo : (x: number, y: number, ...z: string[]) => void +>this : C +>foo : (x: number, y: number, ...z: string[]) => void +>x : number +>y : number + + this.foo(x, y, ...z); +>this.foo(x, y, ...z) : void +>this.foo : (x: number, y: number, ...z: string[]) => void +>this : C +>foo : (x: number, y: number, ...z: string[]) => void +>x : number +>y : number +>...z : string +>z : string[] + } + foo(x: number, y: number, ...z: string[]) { +>foo : (x: number, y: number, ...z: string[]) => void +>x : number +>y : number +>z : string[] + } +} + +class D extends C { +>D : D +>C : C + + constructor() { + super(1, 2); +>super(1, 2) : void +>super : typeof C +>1 : number +>2 : number + + super(1, 2, ...a); +>super(1, 2, ...a) : void +>super : typeof C +>1 : number +>2 : number +>...a : string +>a : string[] + } + foo() { +>foo : () => void + + super.foo(1, 2); +>super.foo(1, 2) : void +>super.foo : (x: number, y: number, ...z: string[]) => void +>super : C +>foo : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number + + super.foo(1, 2, ...a); +>super.foo(1, 2, ...a) : void +>super.foo : (x: number, y: number, ...z: string[]) => void +>super : C +>foo : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] + } +} + diff --git a/tests/baselines/reference/callWithSpreadES6.js b/tests/baselines/reference/callWithSpreadES6.js index d6a915f5f36f2..11fa8d6edcdc5 100644 --- a/tests/baselines/reference/callWithSpreadES6.js +++ b/tests/baselines/reference/callWithSpreadES6.js @@ -49,9 +49,6 @@ class D extends C { super.foo(1, 2, ...a); } } - -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); //// [callWithSpreadES6.js] @@ -92,5 +89,3 @@ class D extends C { super.foo(1, 2, ...a); } } -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); diff --git a/tests/baselines/reference/callWithSpreadES6.symbols b/tests/baselines/reference/callWithSpreadES6.symbols index 94e0b94b002be..008488d0ce905 100644 --- a/tests/baselines/reference/callWithSpreadES6.symbols +++ b/tests/baselines/reference/callWithSpreadES6.symbols @@ -158,9 +158,3 @@ class D extends C { } } -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); ->c : Symbol(c, Decl(callWithSpreadES6.ts, 52, 3)) ->C : Symbol(C, Decl(callWithSpreadES6.ts, 29, 40)) ->a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3)) - diff --git a/tests/baselines/reference/callWithSpreadES6.types b/tests/baselines/reference/callWithSpreadES6.types index 71d3cf9b2df58..ba638207e8a28 100644 --- a/tests/baselines/reference/callWithSpreadES6.types +++ b/tests/baselines/reference/callWithSpreadES6.types @@ -246,13 +246,3 @@ class D extends C { } } -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); ->c : C ->new C(1, 2, ...a) : C ->C : typeof C ->1 : number ->2 : number ->...a : string ->a : string[] - diff --git a/tests/baselines/reference/newWithSpreadES5.js b/tests/baselines/reference/newWithSpreadES5.js index e463f0aaeead8..329861d6742f2 100644 --- a/tests/baselines/reference/newWithSpreadES5.js +++ b/tests/baselines/reference/newWithSpreadES5.js @@ -116,49 +116,50 @@ var h; var i; // Basic expression new f(1, 2, "string"); -new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"])))); +new (f.bind.apply(f, [void 0].concat([1, 2].concat(a)))); +new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"])))); // Call expression new f(1, 2, "string")(); -new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a))))(); -new (Function.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))))()(); +new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))()(); // Property access expression new b.f(1, 2, "string"); -new (Function.bind.apply(b.f, [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(b.f, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_a = b.f).bind.apply(_a, [void 0].concat([1, 2].concat(a)))); +new ((_b = b.f).bind.apply(_b, [void 0].concat([1, 2].concat(a, ["string"])))); // Parenthesised expression new (b.f)(1, 2, "string"); -new (Function.bind.apply((b.f), [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply((b.f), [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_c = (b.f)).bind.apply(_c, [void 0].concat([1, 2].concat(a)))); +new ((_d = (b.f)).bind.apply(_d, [void 0].concat([1, 2].concat(a, ["string"])))); // Element access expression new d[1].f(1, 2, "string"); -new (Function.bind.apply(d[1].f, [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(d[1].f, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_e = d[1].f).bind.apply(_e, [void 0].concat([1, 2].concat(a)))); +new ((_f = d[1].f).bind.apply(_f, [void 0].concat([1, 2].concat(a, ["string"])))); // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); -new (Function.bind.apply(e["a-b"].f, [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(e["a-b"].f, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_g = e["a-b"].f).bind.apply(_g, [void 0].concat([1, 2].concat(a)))); +new ((_h = e["a-b"].f).bind.apply(_h, [void 0].concat([1, 2].concat(a, ["string"])))); // Basic expression new B(1, 2, "string"); -new (Function.bind.apply(B, [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"])))); +new (B.bind.apply(B, [void 0].concat([1, 2].concat(a)))); +new (B.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"])))); // Property access expression new c["a-b"](1, 2, "string"); -new (Function.bind.apply(c["a-b"], [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(c["a-b"], [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_j = c["a-b"]).bind.apply(_j, [void 0].concat([1, 2].concat(a)))); +new ((_k = c["a-b"]).bind.apply(_k, [void 0].concat([1, 2].concat(a, ["string"])))); // Parenthesised expression new (c["a-b"])(1, 2, "string"); -new (Function.bind.apply((c["a-b"]), [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply((c["a-b"]), [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_l = (c["a-b"])).bind.apply(_l, [void 0].concat([1, 2].concat(a)))); +new ((_m = (c["a-b"])).bind.apply(_m, [void 0].concat([1, 2].concat(a, ["string"])))); // Element access expression new g[1]["a-b"](1, 2, "string"); -new (Function.bind.apply(g[1]["a-b"], [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(g[1]["a-b"], [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_o = g[1]["a-b"]).bind.apply(_o, [void 0].concat([1, 2].concat(a)))); +new ((_p = g[1]["a-b"]).bind.apply(_p, [void 0].concat([1, 2].concat(a, ["string"])))); // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); -new (Function.bind.apply(h["a-b"]["a-b"], [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(h["a-b"]["a-b"], [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_q = h["a-b"]["a-b"]).bind.apply(_q, [void 0].concat([1, 2].concat(a)))); +new ((_r = h["a-b"]["a-b"]).bind.apply(_r, [void 0].concat([1, 2].concat(a, ["string"])))); // Element access expression with a number new i["a-b"][1](1, 2, "string"); -new (Function.bind.apply(i["a-b"][1], [void 0].concat([1, 2].concat(a)))); -new (Function.bind.apply(i["a-b"][1], [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_s = i["a-b"][1]).bind.apply(_s, [void 0].concat([1, 2].concat(a)))); +new ((_t = i["a-b"][1]).bind.apply(_t, [void 0].concat([1, 2].concat(a, ["string"])))); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread.ts index 9acba00697a20..245028db3d425 100644 --- a/tests/cases/conformance/expressions/functionCalls/callWithSpread.ts +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread.ts @@ -47,6 +47,3 @@ class D extends C { super.foo(1, 2, ...a); } } - -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts index 2f7d16ba368a0..accb6df135d25 100644 --- a/tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts @@ -49,6 +49,3 @@ class D extends C { super.foo(1, 2, ...a); } } - -// Only supported in when target is ES6 -var c = new C(1, 2, ...a); From 1be34f191ef91fc768e3788007e3d47bb84f60ad Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Thu, 14 May 2015 12:33:15 +0800 Subject: [PATCH 05/11] Changes to emitCallTarget --- src/compiler/emitter.ts | 49 +++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8f33cc151e7d5..876698609ebf1 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1853,6 +1853,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); write(")"); } + + function emitBracedEnclosedCommaList(nodes: Node[]) { + write("("); + emitCommaList(nodes); + write(")"); + } function emitCallExpression(node: CallExpression) { if (languageVersion < ScriptTarget.ES6 && hasSpreadElement(node.arguments)) { @@ -1865,7 +1871,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { superCall = true; } else { - emit(node.expression); + if (node.expression.kind === SyntaxKind.NewExpression) { + emitNewExpression(node.expression, /*emitCallHelper*/true); + emitBracedEnclosedCommaList(node.arguments); + return; + } + else { + emit(node.expression); + } superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (node.expression).expression.kind === SyntaxKind.SuperKeyword; } if (superCall && languageVersion < ScriptTarget.ES6) { @@ -1878,13 +1891,27 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(")"); } else { - write("("); - emitCommaList(node.arguments); - write(")"); + emitBracedEnclosedCommaList(node.arguments); } } - - function emitNewExpression(node: NewExpression) { + + /** Emit a new expression. + * + * Emit call helper: + * When we are emitting a call expression from a new expressions with spread syntax in ES5 + * we need an argument to help this function decide whether it should emit a pair of extra + * braces "()" at the end. These extra braces are there to help the expression to not be + * consumed by the new expression directly. + * + * Example: + * + * new Array(...arguments)(); + * + * Should be transpiled into ES5: + * + * new (Array.bind.apply(Array, [void 0].concat(arguments)))()() + */ + function emitNewExpression(node: NewExpression, emitCallHelper = false) { write("new "); // Spread operator logic can be supported in new expressions in ES5 using a combination @@ -1898,7 +1925,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // Could be transpiled into ES5: // // var arguments = [1, 2, 3, 4, 5]; - // new (Function.bind.apply(Array, [void 0].concat(arguments))); + // new (Array.bind.apply(Array, [void 0].concat(arguments))); // // `[void 0]` is the first argument which represents `thisArg` to the bind method above. // And `thisArg` will be set to the return value of the constructor when instantiated @@ -1909,11 +1936,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { hasSpreadElement(node.arguments)) { write("("); - write("Function.bind.apply("); - emit(node.expression); + let target = emitCallTarget(node.expression); + write(".bind.apply("); + emit(target); write(", [void 0].concat("); emitListWithSpread(node.arguments, /*multiline*/false, /*trailingComma*/false); write(")))"); + if (emitCallHelper) { + write("()"); + } } else { emit(node.expression); From b88d5422d2b554c44685331b033cfa5f852471b2 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Fri, 15 May 2015 08:16:01 +0800 Subject: [PATCH 06/11] Adds an always emit of pair of parens in spread syntax in new expression in ES5 --- src/compiler/emitter.ts | 43 +++--------------- tests/baselines/reference/newWithSpreadES5.js | 44 +++++++++---------- 2 files changed, 29 insertions(+), 58 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 876698609ebf1..8027ffaa0d4fa 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1853,12 +1853,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); write(")"); } - - function emitBracedEnclosedCommaList(nodes: Node[]) { - write("("); - emitCommaList(nodes); - write(")"); - } function emitCallExpression(node: CallExpression) { if (languageVersion < ScriptTarget.ES6 && hasSpreadElement(node.arguments)) { @@ -1871,14 +1865,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { superCall = true; } else { - if (node.expression.kind === SyntaxKind.NewExpression) { - emitNewExpression(node.expression, /*emitCallHelper*/true); - emitBracedEnclosedCommaList(node.arguments); - return; - } - else { - emit(node.expression); - } + emit(node.expression); superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (node.expression).expression.kind === SyntaxKind.SuperKeyword; } if (superCall && languageVersion < ScriptTarget.ES6) { @@ -1891,27 +1878,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(")"); } else { - emitBracedEnclosedCommaList(node.arguments); + write("("); + emitCommaList(node.arguments); + write(")"); } } - - /** Emit a new expression. - * - * Emit call helper: - * When we are emitting a call expression from a new expressions with spread syntax in ES5 - * we need an argument to help this function decide whether it should emit a pair of extra - * braces "()" at the end. These extra braces are there to help the expression to not be - * consumed by the new expression directly. - * - * Example: - * - * new Array(...arguments)(); - * - * Should be transpiled into ES5: - * - * new (Array.bind.apply(Array, [void 0].concat(arguments)))()() - */ - function emitNewExpression(node: NewExpression, emitCallHelper = false) { + + function emitNewExpression(node: NewExpression) { write("new "); // Spread operator logic can be supported in new expressions in ES5 using a combination @@ -1942,9 +1915,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(", [void 0].concat("); emitListWithSpread(node.arguments, /*multiline*/false, /*trailingComma*/false); write(")))"); - if (emitCallHelper) { - write("()"); - } + write("()"); } else { emit(node.expression); diff --git a/tests/baselines/reference/newWithSpreadES5.js b/tests/baselines/reference/newWithSpreadES5.js index 329861d6742f2..22667d80cab4f 100644 --- a/tests/baselines/reference/newWithSpreadES5.js +++ b/tests/baselines/reference/newWithSpreadES5.js @@ -116,50 +116,50 @@ var h; var i; // Basic expression new f(1, 2, "string"); -new (f.bind.apply(f, [void 0].concat([1, 2].concat(a)))); -new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"])))); +new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))))(); +new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Call expression new f(1, 2, "string")(); new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))))()(); new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))()(); // Property access expression new b.f(1, 2, "string"); -new ((_a = b.f).bind.apply(_a, [void 0].concat([1, 2].concat(a)))); -new ((_b = b.f).bind.apply(_b, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_a = b.f).bind.apply(_a, [void 0].concat([1, 2].concat(a))))(); +new ((_b = b.f).bind.apply(_b, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Parenthesised expression new (b.f)(1, 2, "string"); -new ((_c = (b.f)).bind.apply(_c, [void 0].concat([1, 2].concat(a)))); -new ((_d = (b.f)).bind.apply(_d, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_c = (b.f)).bind.apply(_c, [void 0].concat([1, 2].concat(a))))(); +new ((_d = (b.f)).bind.apply(_d, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Element access expression new d[1].f(1, 2, "string"); -new ((_e = d[1].f).bind.apply(_e, [void 0].concat([1, 2].concat(a)))); -new ((_f = d[1].f).bind.apply(_f, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_e = d[1].f).bind.apply(_e, [void 0].concat([1, 2].concat(a))))(); +new ((_f = d[1].f).bind.apply(_f, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); -new ((_g = e["a-b"].f).bind.apply(_g, [void 0].concat([1, 2].concat(a)))); -new ((_h = e["a-b"].f).bind.apply(_h, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_g = e["a-b"].f).bind.apply(_g, [void 0].concat([1, 2].concat(a))))(); +new ((_h = e["a-b"].f).bind.apply(_h, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Basic expression new B(1, 2, "string"); -new (B.bind.apply(B, [void 0].concat([1, 2].concat(a)))); -new (B.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"])))); +new (B.bind.apply(B, [void 0].concat([1, 2].concat(a))))(); +new (B.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Property access expression new c["a-b"](1, 2, "string"); -new ((_j = c["a-b"]).bind.apply(_j, [void 0].concat([1, 2].concat(a)))); -new ((_k = c["a-b"]).bind.apply(_k, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_j = c["a-b"]).bind.apply(_j, [void 0].concat([1, 2].concat(a))))(); +new ((_k = c["a-b"]).bind.apply(_k, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Parenthesised expression new (c["a-b"])(1, 2, "string"); -new ((_l = (c["a-b"])).bind.apply(_l, [void 0].concat([1, 2].concat(a)))); -new ((_m = (c["a-b"])).bind.apply(_m, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_l = (c["a-b"])).bind.apply(_l, [void 0].concat([1, 2].concat(a))))(); +new ((_m = (c["a-b"])).bind.apply(_m, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Element access expression new g[1]["a-b"](1, 2, "string"); -new ((_o = g[1]["a-b"]).bind.apply(_o, [void 0].concat([1, 2].concat(a)))); -new ((_p = g[1]["a-b"]).bind.apply(_p, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_o = g[1]["a-b"]).bind.apply(_o, [void 0].concat([1, 2].concat(a))))(); +new ((_p = g[1]["a-b"]).bind.apply(_p, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); -new ((_q = h["a-b"]["a-b"]).bind.apply(_q, [void 0].concat([1, 2].concat(a)))); -new ((_r = h["a-b"]["a-b"]).bind.apply(_r, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_q = h["a-b"]["a-b"]).bind.apply(_q, [void 0].concat([1, 2].concat(a))))(); +new ((_r = h["a-b"]["a-b"]).bind.apply(_r, [void 0].concat([1, 2].concat(a, ["string"]))))(); // Element access expression with a number new i["a-b"][1](1, 2, "string"); -new ((_s = i["a-b"][1]).bind.apply(_s, [void 0].concat([1, 2].concat(a)))); -new ((_t = i["a-b"][1]).bind.apply(_t, [void 0].concat([1, 2].concat(a, ["string"])))); +new ((_s = i["a-b"][1]).bind.apply(_s, [void 0].concat([1, 2].concat(a))))(); +new ((_t = i["a-b"][1]).bind.apply(_t, [void 0].concat([1, 2].concat(a, ["string"]))))(); var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; From fb63aead59419fb48909e53a3407aab7041886d1 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Fri, 15 May 2015 08:56:24 +0800 Subject: [PATCH 07/11] Adds alwaysCopy argument --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8027ffaa0d4fa..a75065d4e38e4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1913,7 +1913,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*multiline*/false, /*trailingComma*/false); + emitListWithSpread(node.arguments, /*alwaysCopy*/true, /*multiline*/false, /*trailingComma*/false); write(")))"); write("()"); } From e9f8a6f701d1fc14944bbde33be227efb070f053 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Fri, 15 May 2015 09:18:24 +0800 Subject: [PATCH 08/11] Renamed alwaysCopy to needsUniqueCopy --- src/compiler/emitter.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a75065d4e38e4..508b965471996 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1366,7 +1366,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return true; } - function emitListWithSpread(elements: Expression[], alwaysCopy: boolean, multiLine: boolean, trailingComma: boolean) { + function emitListWithSpread(elements: Expression[], needsUniqueCopy: boolean, multiLine: boolean, trailingComma: boolean) { let pos = 0; let group = 0; let length = elements.length; @@ -1383,7 +1383,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { e = (e).expression; emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && alwaysCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) { write(".slice()"); } } @@ -1425,7 +1425,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("]"); } else { - emitListWithSpread(elements, /*alwaysCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, /*trailingComma*/ elements.hasTrailingComma); } } @@ -1850,7 +1850,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("void 0"); } write(", "); - emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); write(")"); } @@ -1913,7 +1913,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*alwaysCopy*/true, /*multiline*/false, /*trailingComma*/false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/false, /*multiline*/false, /*trailingComma*/false); write(")))"); write("()"); } From 629b4bbfdfd2a9199d66e521c997d6c007fd252a Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Fri, 15 May 2015 15:45:08 +0800 Subject: [PATCH 09/11] Saved --- .../expressions/functionCalls/newWithSpreadES5.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts index 0a60c6ff3394f..b826b639a8e81 100644 --- a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts @@ -3,6 +3,8 @@ function f(x: number, y: number, ...z: string[]) { } +function f2(...a: string[]) {} + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -35,6 +37,9 @@ new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); From 78a36c0cee390014637e151df0025c5196338730 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sat, 16 May 2015 16:42:49 +0800 Subject: [PATCH 10/11] Fixes concat style --- src/compiler/emitter.ts | 19 +- .../reference/newWithSpread.errors.txt | 63 +++-- tests/baselines/reference/newWithSpread.js | 16 ++ tests/baselines/reference/newWithSpreadES5.js | 63 +++-- .../reference/newWithSpreadES5.symbols | 255 +++++++++-------- .../reference/newWithSpreadES5.types | 23 ++ tests/baselines/reference/newWithSpreadES6.js | 12 + .../reference/newWithSpreadES6.symbols | 256 ++++++++++-------- .../reference/newWithSpreadES6.types | 24 ++ .../functionCalls/newWithSpread.ts | 7 + .../functionCalls/newWithSpreadES5.ts | 3 +- .../functionCalls/newWithSpreadES6.ts | 7 + 12 files changed, 452 insertions(+), 296 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 508b965471996..955a6b4b6214c 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1366,14 +1366,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { return true; } - function emitListWithSpread(elements: Expression[], needsUniqueCopy: boolean, multiLine: boolean, trailingComma: boolean) { + function emitListWithSpread(elements: Expression[], needsUniqueCopy: boolean, multiLine: boolean, trailingComma: boolean, useConcat: boolean) { let pos = 0; let group = 0; let length = elements.length; while (pos < length) { // Emit using the pattern .concat(, , ...) if (group === 1) { - write(".concat("); + if(useConcat) { + write(".concat("); + } + else { + write(", "); + } } else if (group > 1) { write(", "); @@ -1406,7 +1411,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { group++; } if (group > 1) { - write(")"); + if(useConcat) { + write(")"); + } } } @@ -1426,7 +1433,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { } else { emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0, - /*trailingComma*/ elements.hasTrailingComma); + /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -1850,7 +1857,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write("void 0"); } write(", "); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true); write(")"); } @@ -1913,7 +1920,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { write(".bind.apply("); emit(target); write(", [void 0].concat("); - emitListWithSpread(node.arguments, /*needsUniqueCopy*/false, /*multiline*/false, /*trailingComma*/false); + emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false); write(")))"); write("()"); } diff --git a/tests/baselines/reference/newWithSpread.errors.txt b/tests/baselines/reference/newWithSpread.errors.txt index 2b02d91fccc3c..293c7054e4c2f 100644 --- a/tests/baselines/reference/newWithSpread.errors.txt +++ b/tests/baselines/reference/newWithSpread.errors.txt @@ -1,34 +1,39 @@ -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(34,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(35,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(39,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(40,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(44,15): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(45,15): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(49,17): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(50,17): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(54,18): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(55,18): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(59,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(60,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(64,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(65,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(69,20): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(70,20): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(74,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(75,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(79,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(80,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(84,27): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(85,27): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(89,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(90,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(37,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(38,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(41,8): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(42,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(46,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(47,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(51,15): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(52,15): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(56,17): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(57,17): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(61,18): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(62,18): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(66,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(67,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(71,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(72,13): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(76,20): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(77,20): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(81,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(82,22): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(86,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(87,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(91,27): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(92,27): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(96,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(97,23): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. -==== tests/cases/conformance/expressions/functionCalls/newWithSpread.ts (24 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/newWithSpread.ts (26 errors) ==== function f(x: number, y: number, ...z: string[]) { } + function f2(...x: string[]) { + } + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -65,6 +70,14 @@ tests/cases/conformance/expressions/functionCalls/newWithSpread.ts(90,23): error ~~~~ !!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + // Multiple spreads arguments + new f2(...a, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + new f(1 ,2, ...a, ...a); + ~~~~ +!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher. + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); diff --git a/tests/baselines/reference/newWithSpread.js b/tests/baselines/reference/newWithSpread.js index 6fba9e9a9e81b..3161eb9f67e29 100644 --- a/tests/baselines/reference/newWithSpread.js +++ b/tests/baselines/reference/newWithSpread.js @@ -3,6 +3,9 @@ function f(x: number, y: number, ...z: string[]) { } +function f2(...x: string[]) { +} + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -35,6 +38,10 @@ new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1 ,2, ...a, ...a); + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); @@ -97,6 +104,12 @@ function f(x, y) { z[_i - 2] = arguments[_i]; } } +function f2() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} var B = (function () { function B(x, y) { var z = []; @@ -118,6 +131,9 @@ var i; new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1, 2, ...a, ...a); // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); diff --git a/tests/baselines/reference/newWithSpreadES5.js b/tests/baselines/reference/newWithSpreadES5.js index 22667d80cab4f..f74702662731e 100644 --- a/tests/baselines/reference/newWithSpreadES5.js +++ b/tests/baselines/reference/newWithSpreadES5.js @@ -3,6 +3,8 @@ function f(x: number, y: number, ...z: string[]) { } +function f2(...x: string[]) {} + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -35,6 +37,10 @@ new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1 ,2, ...a, ...a); + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); @@ -97,6 +103,12 @@ function f(x, y) { z[_i - 2] = arguments[_i]; } } +function f2() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} var B = (function () { function B(x, y) { var z = []; @@ -116,50 +128,53 @@ var h; var i; // Basic expression new f(1, 2, "string"); -new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))))(); -new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new (f.bind.apply(f, [void 0].concat([1, 2], a)))(); +new (f.bind.apply(f, [void 0].concat([1, 2], a, ["string"])))(); +// Multiple spreads arguments +new (f2.bind.apply(f2, [void 0].concat(a, a)))(); +new (f.bind.apply(f, [void 0].concat([1, 2], a, a)))(); // Call expression new f(1, 2, "string")(); -new (f.bind.apply(f, [void 0].concat([1, 2].concat(a))))()(); -new (f.bind.apply(f, [void 0].concat([1, 2].concat(a, ["string"]))))()(); +new (f.bind.apply(f, [void 0].concat([1, 2], a)))()(); +new (f.bind.apply(f, [void 0].concat([1, 2], a, ["string"])))()(); // Property access expression new b.f(1, 2, "string"); -new ((_a = b.f).bind.apply(_a, [void 0].concat([1, 2].concat(a))))(); -new ((_b = b.f).bind.apply(_b, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_a = b.f).bind.apply(_a, [void 0].concat([1, 2], a)))(); +new ((_b = b.f).bind.apply(_b, [void 0].concat([1, 2], a, ["string"])))(); // Parenthesised expression new (b.f)(1, 2, "string"); -new ((_c = (b.f)).bind.apply(_c, [void 0].concat([1, 2].concat(a))))(); -new ((_d = (b.f)).bind.apply(_d, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_c = (b.f)).bind.apply(_c, [void 0].concat([1, 2], a)))(); +new ((_d = (b.f)).bind.apply(_d, [void 0].concat([1, 2], a, ["string"])))(); // Element access expression new d[1].f(1, 2, "string"); -new ((_e = d[1].f).bind.apply(_e, [void 0].concat([1, 2].concat(a))))(); -new ((_f = d[1].f).bind.apply(_f, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_e = d[1].f).bind.apply(_e, [void 0].concat([1, 2], a)))(); +new ((_f = d[1].f).bind.apply(_f, [void 0].concat([1, 2], a, ["string"])))(); // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); -new ((_g = e["a-b"].f).bind.apply(_g, [void 0].concat([1, 2].concat(a))))(); -new ((_h = e["a-b"].f).bind.apply(_h, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_g = e["a-b"].f).bind.apply(_g, [void 0].concat([1, 2], a)))(); +new ((_h = e["a-b"].f).bind.apply(_h, [void 0].concat([1, 2], a, ["string"])))(); // Basic expression new B(1, 2, "string"); -new (B.bind.apply(B, [void 0].concat([1, 2].concat(a))))(); -new (B.bind.apply(B, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new (B.bind.apply(B, [void 0].concat([1, 2], a)))(); +new (B.bind.apply(B, [void 0].concat([1, 2], a, ["string"])))(); // Property access expression new c["a-b"](1, 2, "string"); -new ((_j = c["a-b"]).bind.apply(_j, [void 0].concat([1, 2].concat(a))))(); -new ((_k = c["a-b"]).bind.apply(_k, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_j = c["a-b"]).bind.apply(_j, [void 0].concat([1, 2], a)))(); +new ((_k = c["a-b"]).bind.apply(_k, [void 0].concat([1, 2], a, ["string"])))(); // Parenthesised expression new (c["a-b"])(1, 2, "string"); -new ((_l = (c["a-b"])).bind.apply(_l, [void 0].concat([1, 2].concat(a))))(); -new ((_m = (c["a-b"])).bind.apply(_m, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_l = (c["a-b"])).bind.apply(_l, [void 0].concat([1, 2], a)))(); +new ((_m = (c["a-b"])).bind.apply(_m, [void 0].concat([1, 2], a, ["string"])))(); // Element access expression new g[1]["a-b"](1, 2, "string"); -new ((_o = g[1]["a-b"]).bind.apply(_o, [void 0].concat([1, 2].concat(a))))(); -new ((_p = g[1]["a-b"]).bind.apply(_p, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_o = g[1]["a-b"]).bind.apply(_o, [void 0].concat([1, 2], a)))(); +new ((_p = g[1]["a-b"]).bind.apply(_p, [void 0].concat([1, 2], a, ["string"])))(); // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); -new ((_q = h["a-b"]["a-b"]).bind.apply(_q, [void 0].concat([1, 2].concat(a))))(); -new ((_r = h["a-b"]["a-b"]).bind.apply(_r, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_q = h["a-b"]["a-b"]).bind.apply(_q, [void 0].concat([1, 2], a)))(); +new ((_r = h["a-b"]["a-b"]).bind.apply(_r, [void 0].concat([1, 2], a, ["string"])))(); // Element access expression with a number new i["a-b"][1](1, 2, "string"); -new ((_s = i["a-b"][1]).bind.apply(_s, [void 0].concat([1, 2].concat(a))))(); -new ((_t = i["a-b"][1]).bind.apply(_t, [void 0].concat([1, 2].concat(a, ["string"]))))(); +new ((_s = i["a-b"][1]).bind.apply(_s, [void 0].concat([1, 2], a)))(); +new ((_t = i["a-b"][1]).bind.apply(_t, [void 0].concat([1, 2], a, ["string"])))(); var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t; diff --git a/tests/baselines/reference/newWithSpreadES5.symbols b/tests/baselines/reference/newWithSpreadES5.symbols index dc37c41f597dc..021674ef33758 100644 --- a/tests/baselines/reference/newWithSpreadES5.symbols +++ b/tests/baselines/reference/newWithSpreadES5.symbols @@ -7,74 +7,78 @@ function f(x: number, y: number, ...z: string[]) { >z : Symbol(z, Decl(newWithSpreadES5.ts, 1, 32)) } +function f2(...x: string[]) {} +>f2 : Symbol(f2, Decl(newWithSpreadES5.ts, 2, 1)) +>x : Symbol(x, Decl(newWithSpreadES5.ts, 4, 12)) + interface A { ->A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 4, 30)) f: { ->f : Symbol(f, Decl(newWithSpreadES5.ts, 4, 13)) +>f : Symbol(f, Decl(newWithSpreadES5.ts, 6, 13)) new (x: number, y: number, ...z: string[]); ->x : Symbol(x, Decl(newWithSpreadES5.ts, 6, 13)) ->y : Symbol(y, Decl(newWithSpreadES5.ts, 6, 23)) ->z : Symbol(z, Decl(newWithSpreadES5.ts, 6, 34)) +>x : Symbol(x, Decl(newWithSpreadES5.ts, 8, 13)) +>y : Symbol(y, Decl(newWithSpreadES5.ts, 8, 23)) +>z : Symbol(z, Decl(newWithSpreadES5.ts, 8, 34)) } } class B { ->B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1)) constructor(x: number, y: number, ...z: string[]) {} ->x : Symbol(x, Decl(newWithSpreadES5.ts, 11, 16)) ->y : Symbol(y, Decl(newWithSpreadES5.ts, 11, 26)) ->z : Symbol(z, Decl(newWithSpreadES5.ts, 11, 37)) +>x : Symbol(x, Decl(newWithSpreadES5.ts, 13, 16)) +>y : Symbol(y, Decl(newWithSpreadES5.ts, 13, 26)) +>z : Symbol(z, Decl(newWithSpreadES5.ts, 13, 37)) } interface C { ->C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1)) "a-b": typeof B; ->B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1)) } interface D { ->D : Symbol(D, Decl(newWithSpreadES5.ts, 16, 1)) +>D : Symbol(D, Decl(newWithSpreadES5.ts, 18, 1)) 1: typeof B; ->B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1)) } var a: string[]; ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) var b: A; ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 4, 30)) var c: C; ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1)) var d: A[]; ->d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) ->A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 27, 3)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 4, 30)) var e: { [key: string]: A }; ->e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) ->key : Symbol(key, Decl(newWithSpreadES5.ts, 26, 10)) ->A : Symbol(A, Decl(newWithSpreadES5.ts, 2, 1)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 28, 3)) +>key : Symbol(key, Decl(newWithSpreadES5.ts, 28, 10)) +>A : Symbol(A, Decl(newWithSpreadES5.ts, 4, 30)) var g: C[]; ->g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) ->C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) +>g : Symbol(g, Decl(newWithSpreadES5.ts, 29, 3)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1)) var h: { [key: string]: C }; ->h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) ->key : Symbol(key, Decl(newWithSpreadES5.ts, 28, 10)) ->C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) +>h : Symbol(h, Decl(newWithSpreadES5.ts, 30, 3)) +>key : Symbol(key, Decl(newWithSpreadES5.ts, 30, 10)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1)) var i: C[][]; ->i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) ->C : Symbol(C, Decl(newWithSpreadES5.ts, 12, 1)) +>i : Symbol(i, Decl(newWithSpreadES5.ts, 31, 3)) +>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1)) // Basic expression new f(1, 2, "string"); @@ -82,11 +86,22 @@ new f(1, 2, "string"); new f(1, 2, ...a); >f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new f(1, 2, ...a, "string"); >f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) + +// Multiple spreads arguments +new f2(...a, ...a); +>f2 : Symbol(f2, Decl(newWithSpreadES5.ts, 2, 1)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) + +new f(1 ,2, ...a, ...a); +>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Call expression new f(1, 2, "string")(); @@ -94,165 +109,165 @@ new f(1, 2, "string")(); new f(1, 2, ...a)(); >f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new f(1, 2, ...a, "string")(); >f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Property access expression new b.f(1, 2, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) new b.f(1, 2, ...a); ->b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new b.f(1, 2, ...a, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Parenthesised expression new (b.f)(1, 2, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) new (b.f)(1, 2, ...a); ->b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new (b.f)(1, 2, ...a, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES5.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>b : Symbol(b, Decl(newWithSpreadES5.ts, 25, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Element access expression new d[1].f(1, 2, "string"); ->d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 27, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) new d[1].f(1, 2, ...a); ->d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 27, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new d[1].f(1, 2, ...a, "string"); ->d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->d : Symbol(d, Decl(newWithSpreadES5.ts, 25, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>d[1].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>d : Symbol(d, Decl(newWithSpreadES5.ts, 27, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); ->e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 28, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) new e["a-b"].f(1, 2, ...a); ->e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 28, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new e["a-b"].f(1, 2, ...a, "string"); ->e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->e : Symbol(e, Decl(newWithSpreadES5.ts, 26, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES5.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>e : Symbol(e, Decl(newWithSpreadES5.ts, 28, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES5.ts, 6, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Basic expression new B(1, 2, "string"); ->B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1)) new B(1, 2, ...a); ->B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new B(1, 2, ...a, "string"); ->B : Symbol(B, Decl(newWithSpreadES5.ts, 8, 1)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Property access expression new c["a-b"](1, 2, "string"); ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) new c["a-b"](1, 2, ...a); ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new c["a-b"](1, 2, ...a, "string"); ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Parenthesised expression new (c["a-b"])(1, 2, "string"); ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) new (c["a-b"])(1, 2, ...a); ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new (c["a-b"])(1, 2, ...a, "string"); ->c : Symbol(c, Decl(newWithSpreadES5.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES5.ts, 26, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Element access expression new g[1]["a-b"](1, 2, "string"); ->g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>g : Symbol(g, Decl(newWithSpreadES5.ts, 29, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) new g[1]["a-b"](1, 2, ...a); ->g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>g : Symbol(g, Decl(newWithSpreadES5.ts, 29, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new g[1]["a-b"](1, 2, ...a, "string"); ->g : Symbol(g, Decl(newWithSpreadES5.ts, 27, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>g : Symbol(g, Decl(newWithSpreadES5.ts, 29, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); ->h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) +>h : Symbol(h, Decl(newWithSpreadES5.ts, 30, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) new h["a-b"]["a-b"](1, 2, ...a); ->h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>h : Symbol(h, Decl(newWithSpreadES5.ts, 30, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new h["a-b"]["a-b"](1, 2, ...a, "string"); ->h : Symbol(h, Decl(newWithSpreadES5.ts, 28, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>h : Symbol(h, Decl(newWithSpreadES5.ts, 30, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES5.ts, 16, 13)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) // Element access expression with a number new i["a-b"][1](1, 2, "string"); ->i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) +>i : Symbol(i, Decl(newWithSpreadES5.ts, 31, 3)) new i["a-b"][1](1, 2, ...a); ->i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>i : Symbol(i, Decl(newWithSpreadES5.ts, 31, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) new i["a-b"][1](1, 2, ...a, "string"); ->i : Symbol(i, Decl(newWithSpreadES5.ts, 29, 3)) ->a : Symbol(a, Decl(newWithSpreadES5.ts, 22, 3)) +>i : Symbol(i, Decl(newWithSpreadES5.ts, 31, 3)) +>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3)) diff --git a/tests/baselines/reference/newWithSpreadES5.types b/tests/baselines/reference/newWithSpreadES5.types index 9948d075befed..a2c83ed6372e0 100644 --- a/tests/baselines/reference/newWithSpreadES5.types +++ b/tests/baselines/reference/newWithSpreadES5.types @@ -7,6 +7,10 @@ function f(x: number, y: number, ...z: string[]) { >z : string[] } +function f2(...x: string[]) {} +>f2 : (...x: string[]) => void +>x : string[] + interface A { >A : A @@ -101,6 +105,25 @@ new f(1, 2, ...a, "string"); >a : string[] >"string" : string +// Multiple spreads arguments +new f2(...a, ...a); +>new f2(...a, ...a) : any +>f2 : (...x: string[]) => void +>...a : string +>a : string[] +>...a : string +>a : string[] + +new f(1 ,2, ...a, ...a); +>new f(1 ,2, ...a, ...a) : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>...a : string +>a : string[] + // Call expression new f(1, 2, "string")(); >new f(1, 2, "string")() : any diff --git a/tests/baselines/reference/newWithSpreadES6.js b/tests/baselines/reference/newWithSpreadES6.js index dae7c9229db80..b712984f05ea9 100644 --- a/tests/baselines/reference/newWithSpreadES6.js +++ b/tests/baselines/reference/newWithSpreadES6.js @@ -3,6 +3,9 @@ function f(x: number, y: number, ...z: string[]) { } +function f2(...x: string[]) { +} + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -35,6 +38,10 @@ new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1 ,2, ...a, ...a); + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); @@ -93,6 +100,8 @@ new i["a-b"][1](1, 2, ...a, "string"); //// [newWithSpreadES6.js] function f(x, y, ...z) { } +function f2(...x) { +} class B { constructor(x, y, ...z) { } @@ -109,6 +118,9 @@ var i; new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1, 2, ...a, ...a); // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); diff --git a/tests/baselines/reference/newWithSpreadES6.symbols b/tests/baselines/reference/newWithSpreadES6.symbols index f16984fb4815a..51a34ad73ef4f 100644 --- a/tests/baselines/reference/newWithSpreadES6.symbols +++ b/tests/baselines/reference/newWithSpreadES6.symbols @@ -7,74 +7,79 @@ function f(x: number, y: number, ...z: string[]) { >z : Symbol(z, Decl(newWithSpreadES6.ts, 1, 32)) } +function f2(...x: string[]) { +>f2 : Symbol(f2, Decl(newWithSpreadES6.ts, 2, 1)) +>x : Symbol(x, Decl(newWithSpreadES6.ts, 4, 12)) +} + interface A { ->A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 5, 1)) f: { ->f : Symbol(f, Decl(newWithSpreadES6.ts, 4, 13)) +>f : Symbol(f, Decl(newWithSpreadES6.ts, 7, 13)) new (x: number, y: number, ...z: string[]); ->x : Symbol(x, Decl(newWithSpreadES6.ts, 6, 13)) ->y : Symbol(y, Decl(newWithSpreadES6.ts, 6, 23)) ->z : Symbol(z, Decl(newWithSpreadES6.ts, 6, 34)) +>x : Symbol(x, Decl(newWithSpreadES6.ts, 9, 13)) +>y : Symbol(y, Decl(newWithSpreadES6.ts, 9, 23)) +>z : Symbol(z, Decl(newWithSpreadES6.ts, 9, 34)) } } class B { ->B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1)) constructor(x: number, y: number, ...z: string[]) {} ->x : Symbol(x, Decl(newWithSpreadES6.ts, 11, 16)) ->y : Symbol(y, Decl(newWithSpreadES6.ts, 11, 26)) ->z : Symbol(z, Decl(newWithSpreadES6.ts, 11, 37)) +>x : Symbol(x, Decl(newWithSpreadES6.ts, 14, 16)) +>y : Symbol(y, Decl(newWithSpreadES6.ts, 14, 26)) +>z : Symbol(z, Decl(newWithSpreadES6.ts, 14, 37)) } interface C { ->C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1)) "a-b": typeof B; ->B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1)) } interface D { ->D : Symbol(D, Decl(newWithSpreadES6.ts, 16, 1)) +>D : Symbol(D, Decl(newWithSpreadES6.ts, 19, 1)) 1: typeof B; ->B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1)) } var a: string[]; ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) var b: A; ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 5, 1)) var c: C; ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1)) var d: A[]; ->d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) ->A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 28, 3)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 5, 1)) var e: { [key: string]: A }; ->e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) ->key : Symbol(key, Decl(newWithSpreadES6.ts, 26, 10)) ->A : Symbol(A, Decl(newWithSpreadES6.ts, 2, 1)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 29, 3)) +>key : Symbol(key, Decl(newWithSpreadES6.ts, 29, 10)) +>A : Symbol(A, Decl(newWithSpreadES6.ts, 5, 1)) var g: C[]; ->g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) ->C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) +>g : Symbol(g, Decl(newWithSpreadES6.ts, 30, 3)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1)) var h: { [key: string]: C }; ->h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) ->key : Symbol(key, Decl(newWithSpreadES6.ts, 28, 10)) ->C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) +>h : Symbol(h, Decl(newWithSpreadES6.ts, 31, 3)) +>key : Symbol(key, Decl(newWithSpreadES6.ts, 31, 10)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1)) var i: C[][]; ->i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) ->C : Symbol(C, Decl(newWithSpreadES6.ts, 12, 1)) +>i : Symbol(i, Decl(newWithSpreadES6.ts, 32, 3)) +>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1)) // Basic expression new f(1, 2, "string"); @@ -82,11 +87,22 @@ new f(1, 2, "string"); new f(1, 2, ...a); >f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new f(1, 2, ...a, "string"); >f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) + +// Multiple spreads arguments +new f2(...a, ...a); +>f2 : Symbol(f2, Decl(newWithSpreadES6.ts, 2, 1)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) + +new f(1 ,2, ...a, ...a); +>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Call expression new f(1, 2, "string")(); @@ -94,165 +110,165 @@ new f(1, 2, "string")(); new f(1, 2, ...a)(); >f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new f(1, 2, ...a, "string")(); >f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Property access expression new b.f(1, 2, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) new b.f(1, 2, ...a); ->b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new b.f(1, 2, ...a, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Parenthesised expression new (b.f)(1, 2, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) new (b.f)(1, 2, ...a); ->b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new (b.f)(1, 2, ...a, "string"); ->b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->b : Symbol(b, Decl(newWithSpreadES6.ts, 23, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>b.f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>b : Symbol(b, Decl(newWithSpreadES6.ts, 26, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Element access expression new d[1].f(1, 2, "string"); ->d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 28, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) new d[1].f(1, 2, ...a); ->d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 28, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new d[1].f(1, 2, ...a, "string"); ->d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->d : Symbol(d, Decl(newWithSpreadES6.ts, 25, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>d[1].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>d : Symbol(d, Decl(newWithSpreadES6.ts, 28, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); ->e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 29, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) new e["a-b"].f(1, 2, ...a); ->e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 29, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new e["a-b"].f(1, 2, ...a, "string"); ->e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->e : Symbol(e, Decl(newWithSpreadES6.ts, 26, 3)) ->f : Symbol(A.f, Decl(newWithSpreadES6.ts, 4, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>e["a-b"].f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>e : Symbol(e, Decl(newWithSpreadES6.ts, 29, 3)) +>f : Symbol(A.f, Decl(newWithSpreadES6.ts, 7, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Basic expression new B(1, 2, "string"); ->B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) +>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1)) new B(1, 2, ...a); ->B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new B(1, 2, ...a, "string"); ->B : Symbol(B, Decl(newWithSpreadES6.ts, 8, 1)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Property access expression new c["a-b"](1, 2, "string"); ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) new c["a-b"](1, 2, ...a); ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new c["a-b"](1, 2, ...a, "string"); ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Parenthesised expression new (c["a-b"])(1, 2, "string"); ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) new (c["a-b"])(1, 2, ...a); ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new (c["a-b"])(1, 2, ...a, "string"); ->c : Symbol(c, Decl(newWithSpreadES6.ts, 24, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>c : Symbol(c, Decl(newWithSpreadES6.ts, 27, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Element access expression new g[1]["a-b"](1, 2, "string"); ->g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>g : Symbol(g, Decl(newWithSpreadES6.ts, 30, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) new g[1]["a-b"](1, 2, ...a); ->g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>g : Symbol(g, Decl(newWithSpreadES6.ts, 30, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new g[1]["a-b"](1, 2, ...a, "string"); ->g : Symbol(g, Decl(newWithSpreadES6.ts, 27, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>g : Symbol(g, Decl(newWithSpreadES6.ts, 30, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); ->h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) +>h : Symbol(h, Decl(newWithSpreadES6.ts, 31, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) new h["a-b"]["a-b"](1, 2, ...a); ->h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>h : Symbol(h, Decl(newWithSpreadES6.ts, 31, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new h["a-b"]["a-b"](1, 2, ...a, "string"); ->h : Symbol(h, Decl(newWithSpreadES6.ts, 28, 3)) ->"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 14, 13)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>h : Symbol(h, Decl(newWithSpreadES6.ts, 31, 3)) +>"a-b" : Symbol(C."a-b", Decl(newWithSpreadES6.ts, 17, 13)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) // Element access expression with a number new i["a-b"][1](1, 2, "string"); ->i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) +>i : Symbol(i, Decl(newWithSpreadES6.ts, 32, 3)) new i["a-b"][1](1, 2, ...a); ->i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>i : Symbol(i, Decl(newWithSpreadES6.ts, 32, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) new i["a-b"][1](1, 2, ...a, "string"); ->i : Symbol(i, Decl(newWithSpreadES6.ts, 29, 3)) ->a : Symbol(a, Decl(newWithSpreadES6.ts, 22, 3)) +>i : Symbol(i, Decl(newWithSpreadES6.ts, 32, 3)) +>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3)) diff --git a/tests/baselines/reference/newWithSpreadES6.types b/tests/baselines/reference/newWithSpreadES6.types index 7be42103419d0..52951729e3de4 100644 --- a/tests/baselines/reference/newWithSpreadES6.types +++ b/tests/baselines/reference/newWithSpreadES6.types @@ -7,6 +7,11 @@ function f(x: number, y: number, ...z: string[]) { >z : string[] } +function f2(...x: string[]) { +>f2 : (...x: string[]) => void +>x : string[] +} + interface A { >A : A @@ -101,6 +106,25 @@ new f(1, 2, ...a, "string"); >a : string[] >"string" : string +// Multiple spreads arguments +new f2(...a, ...a); +>new f2(...a, ...a) : any +>f2 : (...x: string[]) => void +>...a : string +>a : string[] +>...a : string +>a : string[] + +new f(1 ,2, ...a, ...a); +>new f(1 ,2, ...a, ...a) : any +>f : (x: number, y: number, ...z: string[]) => void +>1 : number +>2 : number +>...a : string +>a : string[] +>...a : string +>a : string[] + // Call expression new f(1, 2, "string")(); >new f(1, 2, "string")() : any diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts index 6550658c81401..d17919a703625 100644 --- a/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpread.ts @@ -2,6 +2,9 @@ function f(x: number, y: number, ...z: string[]) { } +function f2(...x: string[]) { +} + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -34,6 +37,10 @@ new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1 ,2, ...a, ...a); + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts index b826b639a8e81..25ef34446699c 100644 --- a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES5.ts @@ -3,7 +3,7 @@ function f(x: number, y: number, ...z: string[]) { } -function f2(...a: string[]) {} +function f2(...x: string[]) {} interface A { f: { @@ -39,6 +39,7 @@ new f(1, 2, ...a, "string"); // Multiple spreads arguments new f2(...a, ...a); +new f(1 ,2, ...a, ...a); // Call expression new f(1, 2, "string")(); diff --git a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts index ec235f7a6199e..0068b6cf80e41 100644 --- a/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts +++ b/tests/cases/conformance/expressions/functionCalls/newWithSpreadES6.ts @@ -3,6 +3,9 @@ function f(x: number, y: number, ...z: string[]) { } +function f2(...x: string[]) { +} + interface A { f: { new (x: number, y: number, ...z: string[]); @@ -35,6 +38,10 @@ new f(1, 2, "string"); new f(1, 2, ...a); new f(1, 2, ...a, "string"); +// Multiple spreads arguments +new f2(...a, ...a); +new f(1 ,2, ...a, ...a); + // Call expression new f(1, 2, "string")(); new f(1, 2, ...a)(); From ccd3de33f344be3104d8f260dbd48fc1dd1194e2 Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Sun, 17 May 2015 09:27:20 +0800 Subject: [PATCH 11/11] Combining else blocks --- src/compiler/emitter.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 955a6b4b6214c..f474926b33959 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1372,15 +1372,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { let length = elements.length; while (pos < length) { // Emit using the pattern .concat(, , ...) - if (group === 1) { - if(useConcat) { - write(".concat("); - } - else { - write(", "); - } + if (group === 1 && useConcat) { + write(".concat("); } - else if (group > 1) { + else if (group > 0) { write(", "); } let e = elements[pos];