Merge pull request #3066 from tinganho/newWithSpread

New with spread
This commit is contained in:
Jason Freeman
2015-05-18 10:23:30 -07:00
25 changed files with 2993 additions and 109 deletions

1
.gitignore vendored
View File

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

View File

@@ -6605,7 +6605,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) {
@@ -7127,10 +7127,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);
}
}
@@ -7148,7 +7148,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) {

View File

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

View File

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

View File

@@ -1366,16 +1366,16 @@ 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, useConcat: boolean) {
let pos = 0;
let group = 0;
let length = elements.length;
while (pos < length) {
// Emit using the pattern <group0>.concat(<group1>, <group2>, ...)
if (group === 1) {
if (group === 1 && useConcat) {
write(".concat(");
}
else if (group > 1) {
else if (group > 0) {
write(", ");
}
let e = elements[pos];
@@ -1383,7 +1383,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
e = (<SpreadElementExpression>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()");
}
}
@@ -1406,7 +1406,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
group++;
}
if (group > 1) {
write(")");
if(useConcat) {
write(")");
}
}
}
@@ -1425,8 +1427,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
write("]");
}
else {
emitListWithSpread(elements, /*alwaysCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
/*trailingComma*/ elements.hasTrailingComma);
emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
/*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true);
}
}
@@ -1850,7 +1852,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, /*useConcat*/ true);
write(")");
}
@@ -1886,11 +1888,44 @@ 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 (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
// 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(")");
let target = emitCallTarget(node.expression);
write(".bind.apply(");
emit(target);
write(", [void 0].concat(");
emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false);
write(")))");
write("()");
}
else {
emit(node.expression);
if (node.arguments) {
write("(");
emitCommaList(node.arguments);
write(")");
}
}
}

View File

@@ -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");
(<Function>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.

View File

@@ -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;

View File

@@ -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))
(<Function>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))
}
}

View File

@@ -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
(<Function>xa[1].foo)(...[1, 2, "abc"]);
>(<Function>xa[1].foo)(...[1, 2, "abc"]) : any
>(<Function>xa[1].foo) : Function
><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[]
}
}

View File

@@ -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);

View File

@@ -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))

View File

@@ -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[]

View File

@@ -0,0 +1,178 @@
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 (26 errors) ====
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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.
// 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)();
~~~~
!!! 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.

View File

@@ -0,0 +1,180 @@
//// [newWithSpread.ts]
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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");
// 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)();
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];
}
}
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 = [];
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");
// 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)();
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");

View File

@@ -0,0 +1,180 @@
//// [newWithSpreadES5.ts]
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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");
// 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)();
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];
}
}
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 = [];
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.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], 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], 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], 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], 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], 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], 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], 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], 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], 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], 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], 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;

View File

@@ -0,0 +1,273 @@
=== 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))
}
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, 4, 30))
f: {
>f : Symbol(f, Decl(newWithSpreadES5.ts, 6, 13))
new (x: number, y: number, ...z: string[]);
>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, 10, 1))
constructor(x: number, y: number, ...z: string[]) {}
>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, 14, 1))
"a-b": typeof B;
>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1))
}
interface D {
>D : Symbol(D, Decl(newWithSpreadES5.ts, 18, 1))
1: typeof B;
>B : Symbol(B, Decl(newWithSpreadES5.ts, 10, 1))
}
var a: string[];
>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3))
var b: A;
>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, 26, 3))
>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1))
var d: A[];
>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, 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, 29, 3))
>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 1))
var h: { [key: string]: C };
>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, 31, 3))
>C : Symbol(C, Decl(newWithSpreadES5.ts, 14, 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, 24, 3))
new f(1, 2, ...a, "string");
>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0))
>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")();
>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, 24, 3))
new f(1, 2, ...a, "string")();
>f : Symbol(f, Decl(newWithSpreadES5.ts, 0, 0))
>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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 10, 1))
new B(1, 2, ...a);
>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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 31, 3))
new i["a-b"][1](1, 2, ...a);
>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, 31, 3))
>a : Symbol(a, Decl(newWithSpreadES5.ts, 24, 3))

View File

@@ -0,0 +1,494 @@
=== 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[]
}
function f2(...x: string[]) {}
>f2 : (...x: string[]) => void
>x : 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
// 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
>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

View File

@@ -0,0 +1,167 @@
//// [newWithSpreadES6.ts]
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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");
// 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)();
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) {
}
function f2(...x) {
}
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");
// 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)();
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");

View File

@@ -0,0 +1,274 @@
=== 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))
}
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, 5, 1))
f: {
>f : Symbol(f, Decl(newWithSpreadES6.ts, 7, 13))
new (x: number, y: number, ...z: string[]);
>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, 11, 1))
constructor(x: number, y: number, ...z: string[]) {}
>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, 15, 1))
"a-b": typeof B;
>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1))
}
interface D {
>D : Symbol(D, Decl(newWithSpreadES6.ts, 19, 1))
1: typeof B;
>B : Symbol(B, Decl(newWithSpreadES6.ts, 11, 1))
}
var a: string[];
>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3))
var b: A;
>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, 27, 3))
>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1))
var d: A[];
>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, 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, 30, 3))
>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 1))
var h: { [key: string]: C };
>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, 32, 3))
>C : Symbol(C, Decl(newWithSpreadES6.ts, 15, 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, 25, 3))
new f(1, 2, ...a, "string");
>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0))
>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")();
>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, 25, 3))
new f(1, 2, ...a, "string")();
>f : Symbol(f, Decl(newWithSpreadES6.ts, 0, 0))
>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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 11, 1))
new B(1, 2, ...a);
>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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 32, 3))
new i["a-b"][1](1, 2, ...a);
>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, 32, 3))
>a : Symbol(a, Decl(newWithSpreadES6.ts, 25, 3))

View File

@@ -0,0 +1,495 @@
=== 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[]
}
function f2(...x: string[]) {
>f2 : (...x: string[]) => void
>x : 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
// 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
>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

View File

@@ -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);

View File

@@ -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);

View File

@@ -0,0 +1,97 @@
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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");
// 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)();
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");

View File

@@ -0,0 +1,97 @@
//@target: ES5
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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");
// 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)();
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");

View File

@@ -0,0 +1,98 @@
//@target: ES6
function f(x: number, y: number, ...z: string[]) {
}
function f2(...x: 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");
// 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)();
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");