Add tests for array destructuring of iterables
This commit is contained in:
parent
a477b63420
commit
e1f2fbff63
28
tests/baselines/reference/iterableArrayPattern1.js
Normal file
28
tests/baselines/reference/iterableArrayPattern1.js
Normal 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;
|
||||
}
|
||||
}
|
36
tests/baselines/reference/iterableArrayPattern1.types
Normal file
36
tests/baselines/reference/iterableArrayPattern1.types
Normal 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
|
||||
}
|
||||
}
|
24
tests/baselines/reference/iterableArrayPattern10.errors.txt
Normal file
24
tests/baselines/reference/iterableArrayPattern10.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern10.js
Normal file
37
tests/baselines/reference/iterableArrayPattern10.js
Normal 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;
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern11.js
Normal file
37
tests/baselines/reference/iterableArrayPattern11.js
Normal 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;
|
||||
}
|
||||
}
|
52
tests/baselines/reference/iterableArrayPattern11.types
Normal file
52
tests/baselines/reference/iterableArrayPattern11.types
Normal 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
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern12.js
Normal file
37
tests/baselines/reference/iterableArrayPattern12.js
Normal 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;
|
||||
}
|
||||
}
|
52
tests/baselines/reference/iterableArrayPattern12.types
Normal file
52
tests/baselines/reference/iterableArrayPattern12.types
Normal 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
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern13.js
Normal file
37
tests/baselines/reference/iterableArrayPattern13.js
Normal 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;
|
||||
}
|
||||
}
|
50
tests/baselines/reference/iterableArrayPattern13.types
Normal file
50
tests/baselines/reference/iterableArrayPattern13.types
Normal 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
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern14.js
Normal file
37
tests/baselines/reference/iterableArrayPattern14.js
Normal 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;
|
||||
}
|
||||
}
|
50
tests/baselines/reference/iterableArrayPattern14.types
Normal file
50
tests/baselines/reference/iterableArrayPattern14.types
Normal 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
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern15.js
Normal file
37
tests/baselines/reference/iterableArrayPattern15.js
Normal 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;
|
||||
}
|
||||
}
|
52
tests/baselines/reference/iterableArrayPattern15.types
Normal file
52
tests/baselines/reference/iterableArrayPattern15.types
Normal 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
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern16.errors.txt
Normal file
37
tests/baselines/reference/iterableArrayPattern16.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
61
tests/baselines/reference/iterableArrayPattern16.js
Normal file
61
tests/baselines/reference/iterableArrayPattern16.js
Normal 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;
|
||||
}
|
||||
}
|
24
tests/baselines/reference/iterableArrayPattern17.errors.txt
Normal file
24
tests/baselines/reference/iterableArrayPattern17.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern17.js
Normal file
37
tests/baselines/reference/iterableArrayPattern17.js
Normal 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;
|
||||
}
|
||||
}
|
24
tests/baselines/reference/iterableArrayPattern18.errors.txt
Normal file
24
tests/baselines/reference/iterableArrayPattern18.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
37
tests/baselines/reference/iterableArrayPattern18.js
Normal file
37
tests/baselines/reference/iterableArrayPattern18.js
Normal 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;
|
||||
}
|
||||
}
|
24
tests/baselines/reference/iterableArrayPattern19.errors.txt
Normal file
24
tests/baselines/reference/iterableArrayPattern19.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
39
tests/baselines/reference/iterableArrayPattern19.js
Normal file
39
tests/baselines/reference/iterableArrayPattern19.js
Normal 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;
|
||||
}
|
||||
}
|
28
tests/baselines/reference/iterableArrayPattern2.js
Normal file
28
tests/baselines/reference/iterableArrayPattern2.js
Normal 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;
|
||||
}
|
||||
}
|
36
tests/baselines/reference/iterableArrayPattern2.types
Normal file
36
tests/baselines/reference/iterableArrayPattern2.types
Normal 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
|
||||
}
|
||||
}
|
41
tests/baselines/reference/iterableArrayPattern20.js
Normal file
41
tests/baselines/reference/iterableArrayPattern20.js
Normal 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;
|
||||
}
|
||||
}
|
58
tests/baselines/reference/iterableArrayPattern20.types
Normal file
58
tests/baselines/reference/iterableArrayPattern20.types
Normal 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
|
||||
}
|
||||
}
|
|
@ -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.
|
8
tests/baselines/reference/iterableArrayPattern21.js
Normal file
8
tests/baselines/reference/iterableArrayPattern21.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [iterableArrayPattern21.ts]
|
||||
var [a, b] = { 0: "", 1: true };
|
||||
|
||||
//// [iterableArrayPattern21.js]
|
||||
var [a, b] = {
|
||||
0: "",
|
||||
1: true
|
||||
};
|
|
@ -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.
|
8
tests/baselines/reference/iterableArrayPattern22.js
Normal file
8
tests/baselines/reference/iterableArrayPattern22.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [iterableArrayPattern22.ts]
|
||||
var [...a] = { 0: "", 1: true };
|
||||
|
||||
//// [iterableArrayPattern22.js]
|
||||
var [...a] = {
|
||||
0: "",
|
||||
1: true
|
||||
};
|
|
@ -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.
|
13
tests/baselines/reference/iterableArrayPattern23.js
Normal file
13
tests/baselines/reference/iterableArrayPattern23.js
Normal 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
|
||||
};
|
|
@ -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.
|
13
tests/baselines/reference/iterableArrayPattern24.js
Normal file
13
tests/baselines/reference/iterableArrayPattern24.js
Normal 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
|
||||
};
|
|
@ -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]]));
|
17
tests/baselines/reference/iterableArrayPattern25.js
Normal file
17
tests/baselines/reference/iterableArrayPattern25.js
Normal 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
|
||||
]
|
||||
]));
|
10
tests/baselines/reference/iterableArrayPattern26.errors.txt
Normal file
10
tests/baselines/reference/iterableArrayPattern26.errors.txt
Normal 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>'.
|
17
tests/baselines/reference/iterableArrayPattern26.js
Normal file
17
tests/baselines/reference/iterableArrayPattern26.js
Normal 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
|
||||
]
|
||||
]));
|
17
tests/baselines/reference/iterableArrayPattern27.js
Normal file
17
tests/baselines/reference/iterableArrayPattern27.js
Normal 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
|
||||
]
|
||||
]));
|
18
tests/baselines/reference/iterableArrayPattern27.types
Normal file
18
tests/baselines/reference/iterableArrayPattern27.types
Normal 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]
|
||||
|
10
tests/baselines/reference/iterableArrayPattern28.errors.txt
Normal file
10
tests/baselines/reference/iterableArrayPattern28.errors.txt
Normal 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'.
|
17
tests/baselines/reference/iterableArrayPattern28.js
Normal file
17
tests/baselines/reference/iterableArrayPattern28.js
Normal 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
|
||||
]
|
||||
]));
|
12
tests/baselines/reference/iterableArrayPattern29.errors.txt
Normal file
12
tests/baselines/reference/iterableArrayPattern29.errors.txt
Normal 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'.
|
17
tests/baselines/reference/iterableArrayPattern29.js
Normal file
17
tests/baselines/reference/iterableArrayPattern29.js
Normal 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
|
||||
]
|
||||
]));
|
39
tests/baselines/reference/iterableArrayPattern3.js
Normal file
39
tests/baselines/reference/iterableArrayPattern3.js
Normal 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;
|
||||
}
|
||||
}
|
53
tests/baselines/reference/iterableArrayPattern3.types
Normal file
53
tests/baselines/reference/iterableArrayPattern3.types
Normal 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
|
||||
}
|
||||
}
|
14
tests/baselines/reference/iterableArrayPattern30.js
Normal file
14
tests/baselines/reference/iterableArrayPattern30.js
Normal 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
|
||||
]
|
||||
]);
|
12
tests/baselines/reference/iterableArrayPattern30.types
Normal file
12
tests/baselines/reference/iterableArrayPattern30.types
Normal 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]
|
||||
|
39
tests/baselines/reference/iterableArrayPattern4.js
Normal file
39
tests/baselines/reference/iterableArrayPattern4.js
Normal 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;
|
||||
}
|
||||
}
|
54
tests/baselines/reference/iterableArrayPattern4.types
Normal file
54
tests/baselines/reference/iterableArrayPattern4.types
Normal 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
|
||||
}
|
||||
}
|
22
tests/baselines/reference/iterableArrayPattern5.errors.txt
Normal file
22
tests/baselines/reference/iterableArrayPattern5.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
39
tests/baselines/reference/iterableArrayPattern5.js
Normal file
39
tests/baselines/reference/iterableArrayPattern5.js
Normal 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;
|
||||
}
|
||||
}
|
24
tests/baselines/reference/iterableArrayPattern6.errors.txt
Normal file
24
tests/baselines/reference/iterableArrayPattern6.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
39
tests/baselines/reference/iterableArrayPattern6.js
Normal file
39
tests/baselines/reference/iterableArrayPattern6.js
Normal 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;
|
||||
}
|
||||
}
|
24
tests/baselines/reference/iterableArrayPattern7.errors.txt
Normal file
24
tests/baselines/reference/iterableArrayPattern7.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
39
tests/baselines/reference/iterableArrayPattern7.js
Normal file
39
tests/baselines/reference/iterableArrayPattern7.js
Normal 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;
|
||||
}
|
||||
}
|
22
tests/baselines/reference/iterableArrayPattern8.errors.txt
Normal file
22
tests/baselines/reference/iterableArrayPattern8.errors.txt
Normal 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;
|
||||
}
|
||||
}
|
39
tests/baselines/reference/iterableArrayPattern8.js
Normal file
39
tests/baselines/reference/iterableArrayPattern8.js
Normal 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;
|
||||
}
|
||||
}
|
35
tests/baselines/reference/iterableArrayPattern9.js
Normal file
35
tests/baselines/reference/iterableArrayPattern9.js
Normal 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;
|
||||
}
|
||||
}
|
46
tests/baselines/reference/iterableArrayPattern9.types
Normal file
46
tests/baselines/reference/iterableArrayPattern9.types
Normal 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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//@target: ES6
|
||||
var [a, b] = new SymbolIterator;
|
||||
class SymbolIterator {
|
||||
next() {
|
||||
return {
|
||||
value: Symbol(),
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
//@target: ES6
|
||||
var [a, ...b] = new SymbolIterator;
|
||||
class SymbolIterator {
|
||||
next() {
|
||||
return {
|
||||
value: Symbol(),
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
//@target: ES6
|
||||
var [a, b] = { 0: "", 1: true };
|
|
@ -0,0 +1,2 @@
|
|||
//@target: ES6
|
||||
var [...a] = { 0: "", 1: true };
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
var a: string, b: boolean;
|
||||
[a, b] = { 0: "", 1: true };
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
var a: string, b: boolean[];
|
||||
[a, ...b] = { 0: "", 1: true };
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { }
|
||||
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
takeFirstTwoEntries(...new Map([["", 0], ["hello", 1]]));
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
takeFirstTwoEntries(...new Map([["", 0], ["hello", true]]));
|
|
@ -0,0 +1,3 @@
|
|||
//@target: ES6
|
||||
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]: [string, number][]) { }
|
||||
takeFirstTwoEntries(...new Map([["", true], ["hello", true]]));
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
//@target: ES6
|
||||
const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]])
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue