Test non-identifier rest in destructuring assignment

This commit is contained in:
Nathan Shively-Sanders
2016-11-11 08:57:11 -08:00
parent 9b2b2ca19b
commit de9f59a301
3 changed files with 15 additions and 1 deletions

View File

@@ -1,9 +1,10 @@
tests/cases/conformance/types/rest/objectRestNegative.ts(2,10): error TS2462: A rest element must be last in a destructuring pattern
tests/cases/conformance/types/rest/objectRestNegative.ts(3,31): error TS2462: A rest element must be last in a destructuring pattern
tests/cases/conformance/types/rest/objectRestNegative.ts(6,17): error TS2700: Rest types may only be created from object types.
tests/cases/conformance/types/rest/objectRestNegative.ts(11,9): error TS2701: An object rest element must be an identifier.
==== tests/cases/conformance/types/rest/objectRestNegative.ts (3 errors) ====
==== tests/cases/conformance/types/rest/objectRestNegative.ts (4 errors) ====
let o = { a: 1, b: 'no' };
var { ...mustBeLast, a } = o;
~~~~~~~~~~
@@ -18,4 +19,9 @@ tests/cases/conformance/types/rest/objectRestNegative.ts(6,17): error TS2700: Re
!!! error TS2700: Rest types may only be created from object types.
return rest;
}
let rest: { b: string }
({a, ...rest.b + rest.b} = o);
~~~~~~~~~~~~~~~
!!! error TS2701: An object rest element must be an identifier.

View File

@@ -7,6 +7,9 @@ function generic<T extends { x, y }>(t: T) {
let { x, ...rest } = t;
return rest;
}
let rest: { b: string }
({a, ...rest.b + rest.b} = o);
//// [objectRestNegative.js]
@@ -25,3 +28,5 @@ function generic(t) {
var x = t.x, rest = __rest(t, ["x"]);
return rest;
}
var rest;
(a = o.a, o, o);

View File

@@ -6,3 +6,6 @@ function generic<T extends { x, y }>(t: T) {
let { x, ...rest } = t;
return rest;
}
let rest: { b: string }
({a, ...rest.b + rest.b} = o);