mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-04 05:39:27 -05:00
Test non-identifier rest in destructuring assignment
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user