Add tests for array destructuring of iterables

This commit is contained in:
Jason Freeman 2015-03-25 17:36:47 -07:00
parent a477b63420
commit e1f2fbff63
90 changed files with 2140 additions and 0 deletions

View file

@ -0,0 +1,28 @@
//// [iterableArrayPattern1.ts]
var [a, b] = new SymbolIterator;
class SymbolIterator {
next() {
return {
value: Symbol(),
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern1.js]
var [a, b] = new SymbolIterator;
class SymbolIterator {
next() {
return {
value: Symbol(),
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,36 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts ===
var [a, b] = new SymbolIterator;
>a : symbol
>b : symbol
>new SymbolIterator : SymbolIterator
>SymbolIterator : typeof SymbolIterator
class SymbolIterator {
>SymbolIterator : SymbolIterator
next() {
>next : () => { value: symbol; done: boolean; }
return {
>{ value: Symbol(), done: false } : { value: symbol; done: boolean; }
value: Symbol(),
>value : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : SymbolIterator
}
}

View file

@ -0,0 +1,24 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'.
Property '0' is missing in type 'FooIterator'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts (1 errors) ====
function fun([a, b]) { }
fun(new FooIterator);
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'.
!!! error TS2345: Property '0' is missing in type 'FooIterator'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern10.ts]
function fun([a, b]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern10.js]
function fun([a, b]) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern11.ts]
function fun([a, b] = new FooIterator) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern11.js]
function fun([a, b] = new FooIterator) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,52 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts ===
function fun([a, b] = new FooIterator) { }
>fun : ([a, b]?: FooIterator) => void
>a : Foo
>b : Foo
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
fun(new FooIterator);
>fun(new FooIterator) : void
>fun : ([a, b]?: FooIterator) => void
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern12.ts]
function fun([a, ...b] = new FooIterator) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern12.js]
function fun([a, ...b] = new FooIterator) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,52 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts ===
function fun([a, ...b] = new FooIterator) { }
>fun : ([a, ...b]?: FooIterator) => void
>a : Foo
>b : Foo[]
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
fun(new FooIterator);
>fun(new FooIterator) : void
>fun : ([a, ...b]?: FooIterator) => void
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern13.ts]
function fun([a, ...b]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern13.js]
function fun([a, ...b]) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,50 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts ===
function fun([a, ...b]) { }
>fun : ([a, ...b]: Iterable<any>) => void
>a : any
>b : any[]
fun(new FooIterator);
>fun(new FooIterator) : void
>fun : ([a, ...b]: Iterable<any>) => void
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern14.ts]
function fun(...[a, ...b]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern14.js]
function fun(...[a, ...b]) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,50 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts ===
function fun(...[a, ...b]) { }
>fun : (...[a, ...b]: any[]) => void
>a : any
>b : any[]
fun(new FooIterator);
>fun(new FooIterator) : void
>fun : (...[a, ...b]: any[]) => void
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern15.ts]
function fun(...[a, b]: Bar[]) { }
fun(...new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern15.js]
function fun(...[a, b]) {
}
fun(...new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,52 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts ===
function fun(...[a, b]: Bar[]) { }
>fun : (...[a, b]: Bar[]) => void
>a : Bar
>b : Bar
>Bar : Bar
fun(...new FooIterator);
>fun(...new FooIterator) : void
>fun : (...[a, b]: Bar[]) => void
>...new FooIterator : Foo
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,37 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'.
Property '0' is missing in type 'FooIterator'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (1 errors) ====
function fun(...[a, b]: [Bar, Bar][]) { }
fun(...new FooIteratorIterator);
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'.
!!! error TS2345: Property '0' is missing in type 'FooIterator'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
class FooIteratorIterator {
next() {
return {
value: new FooIterator,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,61 @@
//// [iterableArrayPattern16.ts]
function fun(...[a, b]: [Bar, Bar][]) { }
fun(...new FooIteratorIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
class FooIteratorIterator {
next() {
return {
value: new FooIterator,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern16.js]
function fun(...[a, b]) {
}
fun(...new FooIteratorIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
class FooIteratorIterator {
next() {
return {
value: new FooIterator,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,24 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'.
Property 'x' is missing in type 'FooIterator'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (1 errors) ====
function fun(...[a, b]: Bar[]) { }
fun(new FooIterator);
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'.
!!! error TS2345: Property 'x' is missing in type 'FooIterator'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern17.ts]
function fun(...[a, b]: Bar[]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern17.js]
function fun(...[a, b]) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,24 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'.
Property 'length' is missing in type 'FooIterator'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts (1 errors) ====
function fun([a, b]: Bar[]) { }
fun(new FooIterator);
~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'.
!!! error TS2345: Property 'length' is missing in type 'FooIterator'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,37 @@
//// [iterableArrayPattern18.ts]
function fun([a, b]: Bar[]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern18.js]
function fun([a, b]) {
}
fun(new FooIterator);
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,24 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(2,5): error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'.
Property 'length' is missing in type 'FooArrayIterator'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts (1 errors) ====
function fun([[a], b]: Bar[][]) { }
fun(new FooArrayIterator);
~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'.
!!! error TS2345: Property 'length' is missing in type 'FooArrayIterator'.
class Bar { x }
class Foo extends Bar { y }
class FooArrayIterator {
next() {
return {
value: [new Foo],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern19.ts]
function fun([[a], b]: Bar[][]) { }
fun(new FooArrayIterator);
class Bar { x }
class Foo extends Bar { y }
class FooArrayIterator {
next() {
return {
value: [new Foo],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern19.js]
function fun([[a], b]) {
}
fun(new FooArrayIterator);
class Bar {
}
class Foo extends Bar {
}
class FooArrayIterator {
next() {
return {
value: [
new Foo
],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,28 @@
//// [iterableArrayPattern2.ts]
var [a, ...b] = new SymbolIterator;
class SymbolIterator {
next() {
return {
value: Symbol(),
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern2.js]
var [a, ...b] = new SymbolIterator;
class SymbolIterator {
next() {
return {
value: Symbol(),
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,36 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts ===
var [a, ...b] = new SymbolIterator;
>a : symbol
>b : symbol[]
>new SymbolIterator : SymbolIterator
>SymbolIterator : typeof SymbolIterator
class SymbolIterator {
>SymbolIterator : SymbolIterator
next() {
>next : () => { value: symbol; done: boolean; }
return {
>{ value: Symbol(), done: false } : { value: symbol; done: boolean; }
value: Symbol(),
>value : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : SymbolIterator
}
}

View file

@ -0,0 +1,41 @@
//// [iterableArrayPattern20.ts]
function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { }
fun(...new FooArrayIterator);
class Bar { x }
class Foo extends Bar { y }
class FooArrayIterator {
next() {
return {
value: [new Foo],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern20.js]
function fun(...[[a = new Foo], b = [
new Foo
]]) {
}
fun(...new FooArrayIterator);
class Bar {
}
class Foo extends Bar {
}
class FooArrayIterator {
next() {
return {
value: [
new Foo
],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,58 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts ===
function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { }
>fun : (...[[a = new Foo], b = [new Foo]]: Bar[][]) => void
>a : Bar
>new Foo : Foo
>Foo : typeof Foo
>b : Bar[]
>[new Foo] : Foo[]
>new Foo : Foo
>Foo : typeof Foo
>Bar : Bar
fun(...new FooArrayIterator);
>fun(...new FooArrayIterator) : void
>fun : (...[[a = new Foo], b = [new Foo]]: Bar[][]) => void
>...new FooArrayIterator : Foo[]
>new FooArrayIterator : FooArrayIterator
>FooArrayIterator : typeof FooArrayIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooArrayIterator {
>FooArrayIterator : FooArrayIterator
next() {
>next : () => { value: Foo[]; done: boolean; }
return {
>{ value: [new Foo], done: false } : { value: Foo[]; done: boolean; }
value: [new Foo],
>value : Foo[]
>[new Foo] : Foo[]
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooArrayIterator
}
}

View file

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern21.ts(1,5): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern21.ts (1 errors) ====
var [a, b] = { 0: "", 1: true };
~~~~~~
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.

View file

@ -0,0 +1,8 @@
//// [iterableArrayPattern21.ts]
var [a, b] = { 0: "", 1: true };
//// [iterableArrayPattern21.js]
var [a, b] = {
0: "",
1: true
};

View file

@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern22.ts(1,5): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern22.ts (1 errors) ====
var [...a] = { 0: "", 1: true };
~~~~~~
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.

View file

@ -0,0 +1,8 @@
//// [iterableArrayPattern22.ts]
var [...a] = { 0: "", 1: true };
//// [iterableArrayPattern22.js]
var [...a] = {
0: "",
1: true
};

View file

@ -0,0 +1,8 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern23.ts(2,1): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern23.ts (1 errors) ====
var a: string, b: boolean;
[a, b] = { 0: "", 1: true };
~~~~~~
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.

View file

@ -0,0 +1,13 @@
//// [iterableArrayPattern23.ts]
var a: string, b: boolean;
[a, b] = { 0: "", 1: true };
//// [iterableArrayPattern23.js]
var a, b;
[
a,
b
] = {
0: "",
1: true
};

View file

@ -0,0 +1,8 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern24.ts(2,1): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern24.ts (1 errors) ====
var a: string, b: boolean[];
[a, ...b] = { 0: "", 1: true };
~~~~~~~~~
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.

View file

@ -0,0 +1,13 @@
//// [iterableArrayPattern24.ts]
var a: string, b: boolean[];
[a, ...b] = { 0: "", 1: true };
//// [iterableArrayPattern24.js]
var a, b;
[
a,
...b
] = {
0: "",
1: true
};

View file

@ -0,0 +1,8 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(1,30): error TS2370: A rest parameter must be of an array type.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (1 errors) ====
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { }
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2370: A rest parameter must be of an array type.
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));

View file

@ -0,0 +1,17 @@
//// [iterableArrayPattern25.ts]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { }
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
//// [iterableArrayPattern25.js]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) {
}
takeFirstTwoEntries(new Map([
[
"",
0
],
[
"hello",
1
]
]));

View file

@ -0,0 +1,10 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts(2,21): error TS2345: Argument of type 'Map<string, number>' is not assignable to parameter of type '[string, number]'.
Property '0' is missing in type 'Map<string, number>'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern26.ts (1 errors) ====
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type 'Map<string, number>' is not assignable to parameter of type '[string, number]'.
!!! error TS2345: Property '0' is missing in type 'Map<string, number>'.

View file

@ -0,0 +1,17 @@
//// [iterableArrayPattern26.ts]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
//// [iterableArrayPattern26.js]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) {
}
takeFirstTwoEntries(new Map([
[
"",
0
],
[
"hello",
1
]
]));

View file

@ -0,0 +1,17 @@
//// [iterableArrayPattern27.ts]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
//// [iterableArrayPattern27.js]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) {
}
takeFirstTwoEntries(...new Map([
[
"",
0
],
[
"hello",
1
]
]));

View file

@ -0,0 +1,18 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern27.ts ===
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
>takeFirstTwoEntries : (...[[k1, v1], [k2, v2]]: [string, number][]) => void
>k1 : string
>v1 : number
>k2 : string
>v2 : number
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
>takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]])) : void
>takeFirstTwoEntries : (...[[k1, v1], [k2, v2]]: [string, number][]) => void
>...new Map([["", 0], ["hello", 1]]) : [string, number]
>new Map([["", 0], ["hello", 1]]) : Map<string, number>
>Map : MapConstructor
>[["", 0], ["hello", 1]] : [string, number][]
>["", 0] : [string, number]
>["hello", 1] : [string, number]

View file

@ -0,0 +1,10 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,28): error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'boolean'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts (1 errors) ====
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));
~~~
!!! error TS2453: The type argument for type parameter 'V' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'boolean'.

View file

@ -0,0 +1,17 @@
//// [iterableArrayPattern28.ts]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));
//// [iterableArrayPattern28.js]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) {
}
takeFirstTwoEntries(...new Map([
[
"",
0
],
[
"hello",
true
]
]));

View file

@ -0,0 +1,12 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'.
Types of property '1' are incompatible.
Type 'boolean' is not assignable to type 'number'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (1 errors) ====
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", true], ["hello", true]]));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'.
!!! error TS2345: Types of property '1' are incompatible.
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.

View file

@ -0,0 +1,17 @@
//// [iterableArrayPattern29.ts]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", true], ["hello", true]]));
//// [iterableArrayPattern29.js]
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) {
}
takeFirstTwoEntries(...new Map([
[
"",
true
],
[
"hello",
true
]
]));

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern3.ts]
var a: Bar, b: Bar;
[a, b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern3.js]
var a, b;
[
a,
b
] = new FooIterator;
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,53 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts ===
var a: Bar, b: Bar;
>a : Bar
>Bar : Bar
>b : Bar
>Bar : Bar
[a, b] = new FooIterator;
>[a, b] = new FooIterator : FooIterator
>[a, b] : [Bar, Bar]
>a : Bar
>b : Bar
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,14 @@
//// [iterableArrayPattern30.ts]
const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]])
//// [iterableArrayPattern30.js]
const [[k1, v1], [k2, v2]] = new Map([
[
"",
true
],
[
"hello",
true
]
]);

View file

@ -0,0 +1,12 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern30.ts ===
const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]])
>k1 : string
>v1 : boolean
>k2 : string
>v2 : boolean
>new Map([["", true], ["hello", true]]) : Map<string, boolean>
>Map : MapConstructor
>[["", true], ["hello", true]] : [string, boolean][]
>["", true] : [string, boolean]
>["hello", true] : [string, boolean]

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern4.ts]
var a: Bar, b: Bar[];
[a, ...b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern4.js]
var a, b;
[
a,
...b
] = new FooIterator;
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,54 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts ===
var a: Bar, b: Bar[];
>a : Bar
>Bar : Bar
>b : Bar[]
>Bar : Bar
[a, ...b] = new FooIterator;
>[a, ...b] = new FooIterator : FooIterator
>[a, ...b] : Bar[]
>a : Bar
>...b : Bar
>b : Bar[]
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,22 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(2,5): error TS2322: Type 'Foo' is not assignable to type 'string'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts (1 errors) ====
var a: Bar, b: string;
[a, b] = new FooIterator;
~
!!! error TS2322: Type 'Foo' is not assignable to type 'string'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern5.ts]
var a: Bar, b: string;
[a, b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern5.js]
var a, b;
[
a,
b
] = new FooIterator;
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,24 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(2,8): error TS2322: Type 'Foo[]' is not assignable to type 'string[]'.
Type 'Foo' is not assignable to type 'string'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts (1 errors) ====
var a: Bar, b: string[];
[a, ...b] = new FooIterator;
~
!!! error TS2322: Type 'Foo[]' is not assignable to type 'string[]'.
!!! error TS2322: Type 'Foo' is not assignable to type 'string'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern6.ts]
var a: Bar, b: string[];
[a, ...b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern6.js]
var a, b;
[
a,
...b
] = new FooIterator;
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,24 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(2,5): error TS2322: Type 'Foo' is not assignable to type 'string[]'.
Property 'length' is missing in type 'Foo'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts (1 errors) ====
var a: Bar, b: string[];
[a, b] = new FooIterator;
~
!!! error TS2322: Type 'Foo' is not assignable to type 'string[]'.
!!! error TS2322: Property 'length' is missing in type 'Foo'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern7.ts]
var a: Bar, b: string[];
[a, b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern7.js]
var a, b;
[
a,
b
] = new FooIterator;
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,22 @@
tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(2,8): error TS2322: Type 'Foo[]' is not assignable to type 'string'.
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts (1 errors) ====
var a: Bar, b: string;
[a, ...b] = new FooIterator;
~
!!! error TS2322: Type 'Foo[]' is not assignable to type 'string'.
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,39 @@
//// [iterableArrayPattern8.ts]
var a: Bar, b: string;
[a, ...b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern8.js]
var a, b;
[
a,
...b
] = new FooIterator;
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,35 @@
//// [iterableArrayPattern9.ts]
function fun([a, b] = new FooIterator) { }
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
//// [iterableArrayPattern9.js]
function fun([a, b] = new FooIterator) {
}
class Bar {
}
class Foo extends Bar {
}
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,46 @@
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern9.ts ===
function fun([a, b] = new FooIterator) { }
>fun : ([a, b]?: FooIterator) => void
>a : Foo
>b : Foo
>new FooIterator : FooIterator
>FooIterator : typeof FooIterator
class Bar { x }
>Bar : Bar
>x : any
class Foo extends Bar { y }
>Foo : Foo
>Bar : Bar
>y : any
class FooIterator {
>FooIterator : FooIterator
next() {
>next : () => { value: Foo; done: boolean; }
return {
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
value: new Foo,
>value : Foo
>new Foo : Foo
>Foo : typeof Foo
done: false
>done : boolean
};
}
[Symbol.iterator]() {
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
return this;
>this : FooIterator
}
}

View file

@ -0,0 +1,14 @@
//@target: ES6
var [a, b] = new SymbolIterator;
class SymbolIterator {
next() {
return {
value: Symbol(),
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun([a, b]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun([a, b] = new FooIterator) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun([a, ...b] = new FooIterator) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun([a, ...b]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun(...[a, ...b]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun(...[a, b]: Bar[]) { }
fun(...new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,30 @@
//@target: ES6
function fun(...[a, b]: [Bar, Bar][]) { }
fun(...new FooIteratorIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}
class FooIteratorIterator {
next() {
return {
value: new FooIterator,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun(...[a, b]: Bar[]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun([a, b]: Bar[]) { }
fun(new FooIterator);
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun([[a], b]: Bar[][]) { }
fun(new FooArrayIterator);
class Bar { x }
class Foo extends Bar { y }
class FooArrayIterator {
next() {
return {
value: [new Foo],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,14 @@
//@target: ES6
var [a, ...b] = new SymbolIterator;
class SymbolIterator {
next() {
return {
value: Symbol(),
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { }
fun(...new FooArrayIterator);
class Bar { x }
class Foo extends Bar { y }
class FooArrayIterator {
next() {
return {
value: [new Foo],
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,2 @@
//@target: ES6
var [a, b] = { 0: "", 1: true };

View file

@ -0,0 +1,2 @@
//@target: ES6
var [...a] = { 0: "", 1: true };

View file

@ -0,0 +1,3 @@
//@target: ES6
var a: string, b: boolean;
[a, b] = { 0: "", 1: true };

View file

@ -0,0 +1,3 @@
//@target: ES6
var a: string, b: boolean[];
[a, ...b] = { 0: "", 1: true };

View file

@ -0,0 +1,3 @@
//@target: ES6
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { }
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));

View file

@ -0,0 +1,3 @@
//@target: ES6
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));

View file

@ -0,0 +1,3 @@
//@target: ES6
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));

View file

@ -0,0 +1,3 @@
//@target: ES6
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));

View file

@ -0,0 +1,3 @@
//@target: ES6
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
takeFirstTwoEntries(...new Map([["", true], ["hello", true]]));

View file

@ -0,0 +1,17 @@
//@target: ES6
var a: Bar, b: Bar;
[a, b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,2 @@
//@target: ES6
const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]])

View file

@ -0,0 +1,17 @@
//@target: ES6
var a: Bar, b: Bar[];
[a, ...b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
var a: Bar, b: string;
[a, b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
var a: Bar, b: string[];
[a, ...b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
var a: Bar, b: string[];
[a, b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,17 @@
//@target: ES6
var a: Bar, b: string;
[a, ...b] = new FooIterator;
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}

View file

@ -0,0 +1,16 @@
//@target: ES6
function fun([a, b] = new FooIterator) { }
class Bar { x }
class Foo extends Bar { y }
class FooIterator {
next() {
return {
value: new Foo,
done: false
};
}
[Symbol.iterator]() {
return this;
}
}