additional test

This commit is contained in:
Klaus Meinhardt 2018-08-01 11:12:47 +02:00
parent 5f3f6cc5aa
commit 63c80ddaf5
9 changed files with 145 additions and 4 deletions

View file

@ -9,3 +9,4 @@ function a() {
}
var a = _a.a, b = _a.b;
}
//# sourceMappingURL=restParameterWithBindingPattern1.js.map

View file

@ -0,0 +1,2 @@
//// [restParameterWithBindingPattern1.js.map]
{"version":3,"file":"restParameterWithBindingPattern1.js","sourceRoot":"","sources":["restParameterWithBindingPattern1.ts"],"names":[],"mappings":"AAAA,SAAS,CAAC;IAAC,YAAS;SAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;QAAT,uBAAS;;IAAT,IAAI,QAAC,EAAE,QAAC,CAAC;AAAI,CAAC"}

View file

@ -0,0 +1,90 @@
===================================================================
JsFile: restParameterWithBindingPattern1.js
mapUrl: restParameterWithBindingPattern1.js.map
sourceRoot:
sources: restParameterWithBindingPattern1.ts
===================================================================
-------------------------------------------------------------------
emittedFile:tests/cases/compiler/restParameterWithBindingPattern1.js
sourceFile:restParameterWithBindingPattern1.ts
-------------------------------------------------------------------
>>>function a() {
1 >
2 >^^^^^^^^^
3 > ^
4 > ^^^^^^^->
1 >
2 >function
3 > a
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 10) Source(1, 10) + SourceIndex(0)
3 >Emitted(1, 11) Source(1, 11) + SourceIndex(0)
---
>>> var _a = [];
1->^^^^
2 > ^^^^^^^^^^^^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->(
2 > ...{a, b}
1->Emitted(2, 5) Source(1, 12) + SourceIndex(0)
2 >Emitted(2, 17) Source(1, 21) + SourceIndex(0)
---
>>> for (var _i = 0; _i < arguments.length; _i++) {
1->^^^^^^^^^
2 > ^^^^^^^^^^
3 > ^^
4 > ^^^^^^^^^^^^^^^^^^^^^
5 > ^^
6 > ^^^^
1->
2 > ...{a, b}
3 >
4 > ...{a, b}
5 >
6 > ...{a, b}
1->Emitted(3, 10) Source(1, 12) + SourceIndex(0)
2 >Emitted(3, 20) Source(1, 21) + SourceIndex(0)
3 >Emitted(3, 22) Source(1, 12) + SourceIndex(0)
4 >Emitted(3, 43) Source(1, 21) + SourceIndex(0)
5 >Emitted(3, 45) Source(1, 12) + SourceIndex(0)
6 >Emitted(3, 49) Source(1, 21) + SourceIndex(0)
---
>>> _a[_i] = arguments[_i];
1 >^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^
1 >
2 > ...{a, b}
1 >Emitted(4, 9) Source(1, 12) + SourceIndex(0)
2 >Emitted(4, 32) Source(1, 21) + SourceIndex(0)
---
>>> }
>>> var a = _a.a, b = _a.b;
1 >^^^^
2 > ^^^^
3 > ^^^^^^^^
4 > ^^
5 > ^^^^^^^^
6 > ^
1 >
2 > ...{
3 > a
4 > ,
5 > b
6 > }
1 >Emitted(6, 5) Source(1, 12) + SourceIndex(0)
2 >Emitted(6, 9) Source(1, 16) + SourceIndex(0)
3 >Emitted(6, 17) Source(1, 17) + SourceIndex(0)
4 >Emitted(6, 19) Source(1, 19) + SourceIndex(0)
5 >Emitted(6, 27) Source(1, 20) + SourceIndex(0)
6 >Emitted(6, 28) Source(1, 21) + SourceIndex(0)
---
>>>}
1 >
2 >^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >) {
2 >}
1 >Emitted(7, 1) Source(1, 25) + SourceIndex(0)
2 >Emitted(7, 2) Source(1, 26) + SourceIndex(0)
---
>>>//# sourceMappingURL=restParameterWithBindingPattern1.js.map

View file

@ -2,9 +2,12 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Ty
tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'.
tests/cases/compiler/restParameterWithBindingPattern3.ts(3,23): error TS1186: A rest element cannot have an initializer.
tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.
tests/cases/compiler/restParameterWithBindingPattern3.ts(9,19): error TS2322: Type '1' is not assignable to type 'boolean'.
tests/cases/compiler/restParameterWithBindingPattern3.ts(9,29): error TS2322: Type 'true' is not assignable to type 'string'.
tests/cases/compiler/restParameterWithBindingPattern3.ts(9,48): error TS2566: A rest element cannot have a property name.
==== tests/cases/compiler/restParameterWithBindingPattern3.ts (4 errors) ====
==== tests/cases/compiler/restParameterWithBindingPattern3.ts (7 errors) ====
function a(...[a = 1, b = true]: string[]) { }
~
!!! error TS2322: Type '1' is not assignable to type 'string'.
@ -19,4 +22,12 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tu
function d(...[a, , , d]: [boolean, string, number]) { }
~
!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.
!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.
function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { }
~
!!! error TS2322: Type '1' is not assignable to type 'boolean'.
~
!!! error TS2322: Type 'true' is not assignable to type 'string'.
~~~~
!!! error TS2566: A rest element cannot have a property name.

View file

@ -5,9 +5,20 @@ function b(...[...foo = []]: string[]) { }
function c(...{0: a, length, 3: d}: [boolean, string, number]) { }
function d(...[a, , , d]: [boolean, string, number]) { }
function d(...[a, , , d]: [boolean, string, number]) { }
function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { }
//// [restParameterWithBindingPattern3.js]
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
function a() {
var _a = [];
for (var _i = 0; _i < arguments.length; _i++) {
@ -36,3 +47,10 @@ function d() {
}
var a = _a[0], d = _a[3];
}
function e() {
var _a = [];
for (var _i = 0; _i < arguments.length; _i++) {
_a[_i] = arguments[_i];
}
var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c, rest = __rest(_a, [0, 1]);
}

View file

@ -19,3 +19,9 @@ function d(...[a, , , d]: [boolean, string, number]) { }
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 6, 15))
>d : Symbol(d, Decl(restParameterWithBindingPattern3.ts, 6, 21))
function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { }
>e : Symbol(e, Decl(restParameterWithBindingPattern3.ts, 6, 56))
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 8, 15))
>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 8, 24))
>rest : Symbol(rest, Decl(restParameterWithBindingPattern3.ts, 8, 37))

View file

@ -24,3 +24,12 @@ function d(...[a, , , d]: [boolean, string, number]) { }
> : undefined
>d : any
function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { }
>e : (__0_0: boolean, __0_1: string, __0_2: number) => void
>a : boolean
>1 : 1
>b : string
>true : true
>rest : any
>rest : { [n: number]: string | number | boolean; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray<string | number | boolean>[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray<string | number | boolean>)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => boolean, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map<U>(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter<S extends string | number | boolean>(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => any, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce<U>(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight<U>(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; }

View file

@ -1 +1,3 @@
// @sourcemap: true
function a(...{a, b}) { }

View file

@ -4,4 +4,6 @@ function b(...[...foo = []]: string[]) { }
function c(...{0: a, length, 3: d}: [boolean, string, number]) { }
function d(...[a, , , d]: [boolean, string, number]) { }
function d(...[a, , , d]: [boolean, string, number]) { }
function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { }