Skip to content

Commit 498d978

Browse files
committed
Test object rest parameter emit: methods/accessors
1 parent b4d3bca commit 498d978

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

tests/baselines/reference/objectRestParameter.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void);
66
suddenly(({ x: a, ...rest }) => rest.y);
77
suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka);
88

9+
class C {
10+
m({ a, ...clone }: { a: number, b: string}): void {
11+
// actually, never mind, don't clone
12+
}
13+
set p({ a, ...clone }: { a: number, b: string}) {
14+
// actually, never mind, don't clone
15+
}
16+
}
17+
918

1019

1120
//// [objectRestParameter.js]
@@ -26,3 +35,13 @@ suddenly((_a = { x: { z: 1, ka: 1 }, y: 'noo' }) => {
2635
var _b = _a.x, { z = 12 } = _b, nested = __rest(_b, ["z"]), rest = __rest(_a, ["x"]);
2736
return rest.y + nested.ka;
2837
});
38+
class C {
39+
m(_a) {
40+
var { a } = _a, clone = __rest(_a, ["a"]);
41+
// actually, never mind, don't clone
42+
}
43+
set p(_a) {
44+
var { a } = _a, clone = __rest(_a, ["a"]);
45+
// actually, never mind, don't clone
46+
}
47+
}

tests/baselines/reference/objectRestParameter.symbols

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,27 @@ suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo'
4242
>nested : Symbol(nested, Decl(objectRestParameter.ts, 5, 24))
4343
>ka : Symbol(ka, Decl(objectRestParameter.ts, 3, 42))
4444

45+
class C {
46+
>C : Symbol(C, Decl(objectRestParameter.ts, 5, 107))
47+
48+
m({ a, ...clone }: { a: number, b: string}): void {
49+
>m : Symbol(C.m, Decl(objectRestParameter.ts, 7, 9))
50+
>a : Symbol(a, Decl(objectRestParameter.ts, 8, 7))
51+
>clone : Symbol(clone, Decl(objectRestParameter.ts, 8, 10))
52+
>a : Symbol(a, Decl(objectRestParameter.ts, 8, 24))
53+
>b : Symbol(b, Decl(objectRestParameter.ts, 8, 35))
54+
55+
// actually, never mind, don't clone
56+
}
57+
set p({ a, ...clone }: { a: number, b: string}) {
58+
>p : Symbol(C.p, Decl(objectRestParameter.ts, 10, 5))
59+
>a : Symbol(a, Decl(objectRestParameter.ts, 11, 11))
60+
>clone : Symbol(clone, Decl(objectRestParameter.ts, 11, 14))
61+
>a : Symbol(a, Decl(objectRestParameter.ts, 11, 28))
62+
>b : Symbol(b, Decl(objectRestParameter.ts, 11, 39))
63+
64+
// actually, never mind, don't clone
65+
}
66+
}
67+
4568

tests/baselines/reference/objectRestParameter.types

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,27 @@ suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo'
5353
>nested : { ka: any; }
5454
>ka : any
5555

56+
class C {
57+
>C : C
58+
59+
m({ a, ...clone }: { a: number, b: string}): void {
60+
>m : ({a, ...clone}: { a: number; b: string; }) => void
61+
>a : number
62+
>clone : { b: string; }
63+
>a : number
64+
>b : string
65+
66+
// actually, never mind, don't clone
67+
}
68+
set p({ a, ...clone }: { a: number, b: string}) {
69+
>p : { a: number; b: string; }
70+
>a : number
71+
>clone : { b: string; }
72+
>a : number
73+
>b : string
74+
75+
// actually, never mind, don't clone
76+
}
77+
}
78+
5679

tests/cases/conformance/types/rest/objectRestParameter.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ declare function suddenly(f: (a: { x: { z, ka }, y: string }) => void);
66
suddenly(({ x: a, ...rest }) => rest.y);
77
suddenly(({ x: { z = 12, ...nested }, ...rest } = { x: { z: 1, ka: 1 }, y: 'noo' }) => rest.y + nested.ka);
88

9+
class C {
10+
m({ a, ...clone }: { a: number, b: string}): void {
11+
// actually, never mind, don't clone
12+
}
13+
set p({ a, ...clone }: { a: number, b: string}) {
14+
// actually, never mind, don't clone
15+
}
16+
}
17+

0 commit comments

Comments
 (0)