Conformance test for 3.8.2.2 and 6.4

This commit is contained in:
Yui T
2015-04-12 16:03:16 -07:00
parent 96995e705a
commit 5039b4becb
24 changed files with 1064 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration.ts(17,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration.ts(18,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'.
Property 'z' is missing in type '{}'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration.ts(19,14): error TS2300: Duplicate identifier 'z'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration.ts(19,18): error TS2300: Duplicate identifier 'z'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration.ts (4 errors) ====
enum Foo { a }
function a({x, a}: { x: number, a: number }) { }
function a1({z: {x, y: {j}}}) { }
function a2({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({z} = {z:10}) { }
function a4({z=10}) { }
function a6({b}: { b: number|string|boolean } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello" , y: { j: Foo.a } }});
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
a3({});
~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'.
!!! error TS2345: Property 'z' is missing in type '{}'.
function a5([z], z: number) { }
~
!!! error TS2300: Duplicate identifier 'z'.
~
!!! error TS2300: Duplicate identifier 'z'.

View File

@@ -0,0 +1,58 @@
//// [destructuringParameterDeclaration.ts]
enum Foo { a }
function a({x, a}: { x: number, a: number }) { }
function a1({z: {x, y: {j}}}) { }
function a2({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({z} = {z:10}) { }
function a4({z=10}) { }
function a6({b}: { b: number|string|boolean } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello" , y: { j: Foo.a } }});
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
a3({});
function a5([z], z: number) { }
//// [destructuringParameterDeclaration.js]
var Foo;
(function (Foo) {
Foo[Foo["a"] = 0] = "a";
})(Foo || (Foo = {}));
function a(_a) {
var x = _a.x, a = _a.a;
}
function a1(_a) {
var _b = _a.z, x = _b.x, j = _b.y.j;
}
function a2(_a) {
var _b = (_a === void 0 ? { z: { x: "hi", y: { j: 1 } } } : _a).z, x = _b.x, j = _b.y.j;
}
function a3(_a) {
var z = (_a === void 0 ? { z: 10 } : _a).z;
}
function a4(_a) {
var _b = _a.z, z = _b === void 0 ? 10 : _b;
}
function a6(_a) {
var b = (_a === void 0 ? { b: "hello" } : _a).b;
}
a2();
a2({ z: { x: "hello", y: { j: Foo.a } } });
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
a3({});
function a5(_a, z) {
var z = _a[0];
}

View File

@@ -0,0 +1,48 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts(5,16): error TS1048: A rest parameter cannot have an initializer.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts(11,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts(12,18): error TS1047: A rest parameter cannot be optional.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts(13,17): error TS1048: A rest parameter cannot have an initializer.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts(16,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
Type 'boolean' is not assignable to type 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts(21,4): error TS2345: Argument of type 'string | boolean' is not assignable to parameter of type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'number'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1.ts (6 errors) ====
type arrayString = Array<String>
type someArray = Array<String> | number[];
type stringOrNumArray = Array<String|Number>;
function a3(...x = [1,2,3]) { }
~
!!! error TS1048: A rest parameter cannot have an initializer.
function a4(...x: (number|string)[]) { }
function a5(...a) { }
function a6(...a: Array<String>) { }
function a7(...a: arrayString) { }
function a8(...a: stringOrNumArray) { }
function a9(...a: someArray) { }
~~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
function a10(...b?) { }
~
!!! error TS1047: A rest parameter cannot be optional.
function a11(...b = [1,2,3]) { }
~
!!! error TS1048: A rest parameter cannot have an initializer.
a4(1, 2, "hello", true);
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);
~~~~~~~~~
!!! error TS2345: Argument of type 'string | boolean' is not assignable to parameter of type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.

View File

@@ -0,0 +1,86 @@
//// [destructuringParameterDeclaration1.ts]
type arrayString = Array<String>
type someArray = Array<String> | number[];
type stringOrNumArray = Array<String|Number>;
function a3(...x = [1,2,3]) { }
function a4(...x: (number|string)[]) { }
function a5(...a) { }
function a6(...a: Array<String>) { }
function a7(...a: arrayString) { }
function a8(...a: stringOrNumArray) { }
function a9(...a: someArray) { }
function a10(...b?) { }
function a11(...b = [1,2,3]) { }
a4(1, 2, "hello", true);
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);
//// [destructuringParameterDeclaration1.js]
function a3() {
if (x === void 0) { x = [1, 2, 3]; }
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
}
}
function a4() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
}
}
function a5() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
}
}
function a6() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
}
}
function a7() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
}
}
function a8() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
}
}
function a9() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
}
}
function a10() {
var b = [];
for (var _i = 0; _i < arguments.length; _i++) {
b[_i - 0] = arguments[_i];
}
}
function a11() {
if (b === void 0) { b = [1, 2, 3]; }
var b = [];
for (var _i = 0; _i < arguments.length; _i++) {
b[_i - 0] = arguments[_i];
}
}
a4(1, 2, "hello", true);
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5(array);
a4.apply(void 0, array);
a4.apply(void 0, array2);

View File

@@ -0,0 +1,48 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(5,16): error TS1048: A rest parameter cannot have an initializer.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(11,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(12,18): error TS1047: A rest parameter cannot be optional.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(13,17): error TS1048: A rest parameter cannot have an initializer.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(16,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
Type 'boolean' is not assignable to type 'number'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts(21,4): error TS2345: Argument of type 'string | boolean' is not assignable to parameter of type 'string | number'.
Type 'boolean' is not assignable to type 'string | number'.
Type 'boolean' is not assignable to type 'number'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES6.ts (6 errors) ====
type arrayString = Array<String>
type someArray = Array<String> | number[];
type stringOrNumArray = Array<String|Number>;
function a3(...x = [1,2,3]) { }
~
!!! error TS1048: A rest parameter cannot have an initializer.
function a4(...x: (number|string)[]) { }
function a5(...a) { }
function a6(...a: Array<String>) { }
function a7(...a: arrayString) { }
function a8(...a: stringOrNumArray) { }
function a9(...a: someArray) { }
~~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
function a10(...b?) { }
~
!!! error TS1047: A rest parameter cannot be optional.
function a11(...b = [1,2,3]) { }
~
!!! error TS1048: A rest parameter cannot have an initializer.
a4(1, 2, "hello", true);
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);
~~~~~~~~~
!!! error TS2345: Argument of type 'string | boolean' is not assignable to parameter of type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.

View File

@@ -0,0 +1,39 @@
//// [destructuringParameterDeclaration1ES6.ts]
type arrayString = Array<String>
type someArray = Array<String> | number[];
type stringOrNumArray = Array<String|Number>;
function a3(...x = [1,2,3]) { }
function a4(...x: (number|string)[]) { }
function a5(...a) { }
function a6(...a: Array<String>) { }
function a7(...a: arrayString) { }
function a8(...a: stringOrNumArray) { }
function a9(...a: someArray) { }
function a10(...b?) { }
function a11(...b = [1,2,3]) { }
a4(1, 2, "hello", true);
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);
//// [destructuringParameterDeclaration1ES6.js]
function a3(...x = [1, 2, 3]) { }
function a4(...x) { }
function a5(...a) { }
function a6(...a) { }
function a7(...a) { }
function a8(...a) { }
function a9(...a) { }
function a10(...b) { }
function a11(...b = [1, 2, 3]) { }
a4(1, 2, "hello", true);
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);

View File

@@ -0,0 +1,56 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,14): error TS1181: Array element destructuring pattern expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,19): error TS1005: '(' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,21): error TS1109: Expression expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,24): error TS1005: '(' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,26): error TS2304: Cannot find name 'public'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,32): error TS1005: ';' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(6,33): error TS1128: Declaration or statement expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,16): error TS1003: Identifier expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,21): error TS1005: '(' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(9,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(12,24): error TS1005: ',' expected.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts (11 errors) ====
"use strict"
function a({while}) { }
function a1({public}) { }
function a2({public: x}) { }
function a3({while: y}) { }
function a4([while, for, public]){ }
~~~~~
!!! error TS1181: Array element destructuring pattern expected.
~
!!! error TS1005: '(' expected.
~~~
!!! error TS1109: Expression expected.
~
!!! error TS1005: '(' expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1128: Declaration or statement expected.
function a5(...while) { }
~~~~~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: '(' expected.
function a6(...public) { }
function a7(...a: string) { }
~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
class C {
constructor(public ...a) { }
~~~
!!! error TS1005: ',' expected.
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });

View File

@@ -0,0 +1,65 @@
//// [destructuringParameterDeclaration2.ts]
"use strict"
function a({while}) { }
function a1({public}) { }
function a2({public: x}) { }
function a3({while: y}) { }
function a4([while, for, public]){ }
function a5(...while) { }
function a6(...public) { }
function a7(...a: string) { }
class C {
constructor(public ...a) { }
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });
//// [destructuringParameterDeclaration2.js]
"use strict";
function a(_a) {
var while = _a.while;
}
function a1(_a) {
var public = _a.public;
}
function a2(_a) {
var x = _a.public;
}
function a3(_a) {
var y = _a.while;
}
while (, )
for (, public; ; )
;
{ }
while () { }
function a6() {
var public = [];
for (var _i = 0; _i < arguments.length; _i++) {
public[_i - 0] = arguments[_i];
}
}
function a7() {
var a = [];
for (var _i = 0; _i < arguments.length; _i++) {
a[_i - 0] = arguments[_i];
}
}
var C = (function () {
function C(public) {
var a = [];
for (var _i = 1; _i < arguments.length; _i++) {
a[_i - 1] = arguments[_i];
}
}
return C;
})();
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });

View File

@@ -0,0 +1,56 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,14): error TS1181: Array element destructuring pattern expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,19): error TS1005: '(' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,21): error TS1109: Expression expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,24): error TS1005: '(' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,26): error TS2304: Cannot find name 'public'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,32): error TS1005: ';' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(6,33): error TS1128: Declaration or statement expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(7,16): error TS1003: Identifier expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(7,21): error TS1005: '(' expected.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(9,13): error TS2370: A rest parameter must be of an array type.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts(12,24): error TS1005: ',' expected.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2ES6.ts (11 errors) ====
"use strict"
function a({while}) { }
function a1({public}) { }
function a2({public: x}) { }
function a3({while: y}) { }
function a4([while, for, public]){ }
~~~~~
!!! error TS1181: Array element destructuring pattern expected.
~
!!! error TS1005: '(' expected.
~~~
!!! error TS1109: Expression expected.
~
!!! error TS1005: '(' expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
~
!!! error TS1128: Declaration or statement expected.
function a5(...while) { }
~~~~~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: '(' expected.
function a6(...public) { }
function a7(...a: string) { }
~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
class C {
constructor(public ...a) { }
~~~
!!! error TS1005: ',' expected.
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });

View File

@@ -0,0 +1,42 @@
//// [destructuringParameterDeclaration2ES6.ts]
"use strict"
function a({while}) { }
function a1({public}) { }
function a2({public: x}) { }
function a3({while: y}) { }
function a4([while, for, public]){ }
function a5(...while) { }
function a6(...public) { }
function a7(...a: string) { }
class C {
constructor(public ...a) { }
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });
//// [destructuringParameterDeclaration2ES6.js]
"use strict";
function a({ while }) { }
function a1({ public }) { }
function a2({ public: x }) { }
function a3({ while: y }) { }
while (, )
for (, public; ; )
;
{ }
while () { }
function a6(...public) { }
function a7(...a) { }
class C {
constructor(public, ...a) {
}
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });

View File

@@ -0,0 +1,51 @@
//// [destructuringParameterDeclaration3.ts]
function a([x, [y, z], [[j]]]) {
return [x, y, z, j];
}
function a1([...x]) {
return [x];
}
function a2({public} = { "public": "1" }) {
return public;
}
function a3({x: { y, z}, j: {k: {a}} }) {
return [y, z, a];
}
function a4({x: { y, z}, j: {k: {a}} } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }): (number| string) [] {
return [y, z, a];
}
function a5({x: { y, z}, j: {k: {a}} }): (number| string) [] {
return [y, z, a];
}
//// [destructuringParameterDeclaration3.js]
function a(_a) {
var x = _a[0], _b = _a[1], y = _b[0], z = _b[1], j = _a[2][0][0];
return [x, y, z, j];
}
function a1(_a) {
var x = _a.slice(0);
return [x];
}
function a2(_a) {
var public = (_a === void 0 ? { "public": "1" } : _a).public;
return public;
}
function a3(_a) {
var _b = _a.x, y = _b.y, z = _b.z, a = _a.j.k.a;
return [y, z, a];
}
function a4(_a) {
var _b = _a === void 0 ? { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } } : _a, _c = _b.x, y = _c.y, z = _c.z, a = _b.j.k.a;
return [y, z, a];
}
function a5(_a) {
var _b = _a.x, y = _b.y, z = _b.z, a = _a.j.k.a;
return [y, z, a];
}

View File

@@ -0,0 +1,92 @@
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3.ts ===
function a([x, [y, z], [[j]]]) {
>a : ([x, [y, z], [[j]]]: [any, [any, any], [[any]]]) => any[]
>x : any
>y : any
>z : any
>j : any
return [x, y, z, j];
>[x, y, z, j] : any[]
>x : any
>y : any
>z : any
>j : any
}
function a1([...x]) {
>a1 : ([...x]: any[]) => any[][]
>x : any[]
return [x];
>[x] : any[][]
>x : any[]
}
function a2({public} = { "public": "1" }) {
>a2 : ({public}?: { "public": string; }) => string
>public : string
>{ "public": "1" } : { "public": string; }
return public;
>public : string
}
function a3({x: { y, z}, j: {k: {a}} }) {
>a3 : ({x: { y, z}, j: {k: {a}} }: { x: { y: any; z: any; }; j: { k: { a: any; }; }; }) => any[]
>x : unknown
>y : any
>z : any
>j : unknown
>k : unknown
>a : any
return [y, z, a];
>[y, z, a] : any[]
>y : any
>z : any
>a : any
}
function a4({x: { y, z}, j: {k: {a}} } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }): (number| string) [] {
>a4 : ({x: { y, z}, j: {k: {a}} }?: { x: { y: number; z: number; }; j: { k: { a: string; }; }; }) => (string | number)[]
>x : unknown
>y : number
>z : number
>j : unknown
>k : unknown
>a : string
>{ x: { y: 1, z: 1 }, j: { k: { a: "hello" } } } : { x: { y: number; z: number; }; j: { k: { a: string; }; }; }
>x : { y: number; z: number; }
>{ y: 1, z: 1 } : { y: number; z: number; }
>y : number
>z : number
>j : { k: { a: string; }; }
>{ k: { a: "hello" } } : { k: { a: string; }; }
>k : { a: string; }
>{ a: "hello" } : { a: string; }
>a : string
return [y, z, a];
>[y, z, a] : (string | number)[]
>y : number
>z : number
>a : string
}
function a5({x: { y, z}, j: {k: {a}} }): (number| string) [] {
>a5 : ({x: { y, z}, j: {k: {a}} }: { x: { y: any; z: any; }; j: { k: { a: any; }; }; }) => (string | number)[]
>x : unknown
>y : any
>z : any
>j : unknown
>k : unknown
>a : any
return [y, z, a];
>[y, z, a] : any[]
>y : any
>z : any
>a : any
}

View File

@@ -0,0 +1,45 @@
//// [destructuringParameterDeclaration3ES6.ts]
function a([x, [y, z], [[j]]]) {
return [x, y, z, j];
}
function a1([...x]) {
return [x];
}
function a2({public} = { "public": "1" }) {
return public;
}
function a3({x: { y, z}, j: {k: {a}} }) {
return [y, z, a];
}
function a4({x: { y, z}, j: {k: {a}} } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }): (number| string) [] {
return [y, z, a];
}
function a5({x: { y, z}, j: {k: {a}} }): (number| string) [] {
return [y, z, a];
}
//// [destructuringParameterDeclaration3ES6.js]
function a([x, [y, z], [[j]]]) {
return [x, y, z, j];
}
function a1([...x]) {
return [x];
}
function a2({ public } = { "public": "1" }) {
return public;
}
function a3({ x: { y, z }, j: { k: { a } } }) {
return [y, z, a];
}
function a4({ x: { y, z }, j: { k: { a } } } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }) {
return [y, z, a];
}
function a5({ x: { y, z }, j: { k: { a } } }) {
return [y, z, a];
}

View File

@@ -0,0 +1,92 @@
=== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration3ES6.ts ===
function a([x, [y, z], [[j]]]) {
>a : ([x, [y, z], [[j]]]: [any, [any, any], [[any]]]) => any[]
>x : any
>y : any
>z : any
>j : any
return [x, y, z, j];
>[x, y, z, j] : any[]
>x : any
>y : any
>z : any
>j : any
}
function a1([...x]) {
>a1 : ([...x]: Iterable<any>) => any[][]
>x : any[]
return [x];
>[x] : any[][]
>x : any[]
}
function a2({public} = { "public": "1" }) {
>a2 : ({public}?: { "public": string; }) => string
>public : string
>{ "public": "1" } : { "public": string; }
return public;
>public : string
}
function a3({x: { y, z}, j: {k: {a}} }) {
>a3 : ({x: { y, z}, j: {k: {a}} }: { x: { y: any; z: any; }; j: { k: { a: any; }; }; }) => any[]
>x : unknown
>y : any
>z : any
>j : unknown
>k : unknown
>a : any
return [y, z, a];
>[y, z, a] : any[]
>y : any
>z : any
>a : any
}
function a4({x: { y, z}, j: {k: {a}} } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }): (number| string) [] {
>a4 : ({x: { y, z}, j: {k: {a}} }?: { x: { y: number; z: number; }; j: { k: { a: string; }; }; }) => (string | number)[]
>x : unknown
>y : number
>z : number
>j : unknown
>k : unknown
>a : string
>{ x: { y: 1, z: 1 }, j: { k: { a: "hello" } } } : { x: { y: number; z: number; }; j: { k: { a: string; }; }; }
>x : { y: number; z: number; }
>{ y: 1, z: 1 } : { y: number; z: number; }
>y : number
>z : number
>j : { k: { a: string; }; }
>{ k: { a: "hello" } } : { k: { a: string; }; }
>k : { a: string; }
>{ a: "hello" } : { a: string; }
>a : string
return [y, z, a];
>[y, z, a] : (string | number)[]
>y : number
>z : number
>a : string
}
function a5({x: { y, z}, j: {k: {a}} }): (number| string) [] {
>a5 : ({x: { y, z}, j: {k: {a}} }: { x: { y: any; z: any; }; j: { k: { a: any; }; }; }) => (string | number)[]
>x : unknown
>y : any
>z : any
>j : unknown
>k : unknown
>a : any
return [y, z, a];
>[y, z, a] : any[]
>y : any
>z : any
>a : any
}

View File

@@ -0,0 +1,37 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclarationES6.ts(17,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclarationES6.ts(18,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'.
Property 'z' is missing in type '{}'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclarationES6.ts(19,14): error TS2300: Duplicate identifier 'z'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclarationES6.ts(19,18): error TS2300: Duplicate identifier 'z'.
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclarationES6.ts (4 errors) ====
enum Foo { a }
function a({x, a}: { x: number, a: number }) { }
function a1({z: {x, y: {j}}}) { }
function a2({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({z} = {z:10}) { }
function a4({z=10}) { }
function a6({b}: { b: number|string|boolean } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello" , y: { j: Foo.a } }});
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
a3({});
~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ z: number; }'.
!!! error TS2345: Property 'z' is missing in type '{}'.
function a5([z], z: number) { }
~
!!! error TS2300: Duplicate identifier 'z'.
~
!!! error TS2300: Duplicate identifier 'z'.

View File

@@ -0,0 +1,44 @@
//// [destructuringParameterDeclarationES6.ts]
enum Foo { a }
function a({x, a}: { x: number, a: number }) { }
function a1({z: {x, y: {j}}}) { }
function a2({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({z} = {z:10}) { }
function a4({z=10}) { }
function a6({b}: { b: number|string|boolean } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello" , y: { j: Foo.a } }});
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
a3({});
function a5([z], z: number) { }
//// [destructuringParameterDeclarationES6.js]
var Foo;
(function (Foo) {
Foo[Foo["a"] = 0] = "a";
})(Foo || (Foo = {}));
function a({ x, a }) { }
function a1({ z: { x, y: { j } } }) { }
function a2({ z: { x, y: { j } } } = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({ z } = { z: 10 }) { }
function a4({ z = 10 }) { }
function a6({ b } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello", y: { j: Foo.a } } });
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
a3({});
function a5([z], z) { }

View File

@@ -0,0 +1,19 @@
enum Foo { a }
function a({x, a}: { x: number, a: number }) { }
function a1({z: {x, y: {j}}}) { }
function a2({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({z} = {z:10}) { }
function a4({z=10}) { }
function a6({b}: { b: number|string|boolean } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello" , y: { j: Foo.a } }});
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
a3({});
function a5([z], z: number) { }

View File

@@ -0,0 +1,21 @@
type arrayString = Array<String>
type someArray = Array<String> | number[];
type stringOrNumArray = Array<String|Number>;
function a3(...x = [1,2,3]) { }
function a4(...x: (number|string)[]) { }
function a5(...a) { }
function a6(...a: Array<String>) { }
function a7(...a: arrayString) { }
function a8(...a: stringOrNumArray) { }
function a9(...a: someArray) { }
function a10(...b?) { }
function a11(...b = [1,2,3]) { }
a4(1, 2, "hello", true);
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);

View File

@@ -0,0 +1,22 @@
// @target: es6
type arrayString = Array<String>
type someArray = Array<String> | number[];
type stringOrNumArray = Array<String|Number>;
function a3(...x = [1,2,3]) { }
function a4(...x: (number|string)[]) { }
function a5(...a) { }
function a6(...a: Array<String>) { }
function a7(...a: arrayString) { }
function a8(...a: stringOrNumArray) { }
function a9(...a: someArray) { }
function a10(...b?) { }
function a11(...b = [1,2,3]) { }
a4(1, 2, "hello", true);
var array = [1, 2, 3];
var array2 = [true, false, "hello"];
a5([...array]);
a4(...array);
a4(...array2);

View File

@@ -0,0 +1,19 @@
"use strict"
function a({while}) { }
function a1({public}) { }
function a2({public: x}) { }
function a3({while: y}) { }
function a4([while, for, public]){ }
function a5(...while) { }
function a6(...public) { }
function a7(...a: string) { }
class C {
constructor(public ...a) { }
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });

View File

@@ -0,0 +1,20 @@
//@target: es6
"use strict"
function a({while}) { }
function a1({public}) { }
function a2({public: x}) { }
function a3({while: y}) { }
function a4([while, for, public]){ }
function a5(...while) { }
function a6(...public) { }
function a7(...a: string) { }
class C {
constructor(public ...a) { }
}
a2({ public: 1 });
a3({ while: 1 });
a({ while: 1 });

View File

@@ -0,0 +1,23 @@
function a([x, [y, z], [[j]]]) {
return [x, y, z, j];
}
function a1([...x]) {
return [x];
}
function a2({public} = { "public": "1" }) {
return public;
}
function a3({x: { y, z}, j: {k: {a}} }) {
return [y, z, a];
}
function a4({x: { y, z}, j: {k: {a}} } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }): (number| string) [] {
return [y, z, a];
}
function a5({x: { y, z}, j: {k: {a}} }): (number| string) [] {
return [y, z, a];
}

View File

@@ -0,0 +1,24 @@
// @target: es6
function a([x, [y, z], [[j]]]) {
return [x, y, z, j];
}
function a1([...x]) {
return [x];
}
function a2({public} = { "public": "1" }) {
return public;
}
function a3({x: { y, z}, j: {k: {a}} }) {
return [y, z, a];
}
function a4({x: { y, z}, j: {k: {a}} } = { x: { y: 1, z: 1 }, j: { k: { a: "hello" } } }): (number| string) [] {
return [y, z, a];
}
function a5({x: { y, z}, j: {k: {a}} }): (number| string) [] {
return [y, z, a];
}

View File

@@ -0,0 +1,20 @@
//@target: es6
enum Foo { a }
function a({x, a}: { x: number, a: number }) { }
function a1({z: {x, y: {j}}}) { }
function a2({z: {x, y: {j}}} = { z: { x: "hi", y: { j: 1 } } }) { }
function a3({z} = {z:10}) { }
function a4({z=10}) { }
function a6({b}: { b: number|string|boolean } = { b: "hello" }) { }
a2();
a2({ z: { x: "hello" , y: { j: Foo.a } }});
a3();
a3({ z: Foo.a });
a4({});
a6({ b: 10 });
a6({ b: true });
// error
a4();
a3({});
function a5([z], z: number) { }