Skip to content

Commit f2bb9b7

Browse files
committed
Test all different possibilities
1 parent d45768e commit f2bb9b7

5 files changed

+446
-190
lines changed

tests/baselines/reference/destructuringUnspreadableIntoRest.errors.txt

+105-52
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,91 @@
1-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(4,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
2-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
3-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(16,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
4-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(17,15): error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
5-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(18,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
6-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(19,15): error TS2339: Property 'getter' does not exist on type '{}'.
7-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(21,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
8-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(22,15): error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
9-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(23,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
10-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(24,15): error TS2339: Property 'setter' does not exist on type '{}'.
11-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(26,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
12-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(27,15): error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
13-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(28,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
14-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(29,15): error TS2339: Property 'method' does not exist on type '{}'.
15-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(39,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
16-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(40,11): error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
17-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(41,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
18-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(42,11): error TS2339: Property 'getter' does not exist on type '{}'.
19-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(44,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
20-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(45,11): error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
21-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(46,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
22-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(47,11): error TS2339: Property 'setter' does not exist on type '{}'.
23-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(49,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
24-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(50,11): error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
25-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(51,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
26-
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339: Property 'method' does not exist on type '{}'.
1+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(21,15): error TS2339: Property 'publicProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
2+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(22,15): error TS2339: Property 'publicProp' does not exist on type '{}'.
3+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(24,15): error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
4+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(25,15): error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
5+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(26,15): error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
6+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(27,15): error TS2339: Property 'privateProp' does not exist on type '{}'.
7+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(29,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
8+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(30,15): error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
9+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(31,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
10+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(32,15): error TS2339: Property 'getter' does not exist on type '{}'.
11+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(34,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
12+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(35,15): error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
13+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(36,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
14+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(37,15): error TS2339: Property 'setter' does not exist on type '{}'.
15+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(39,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
16+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(40,15): error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
17+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(41,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
18+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(42,15): error TS2339: Property 'method' does not exist on type '{}'.
19+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(54,11): error TS2339: Property 'publicProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
20+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(55,11): error TS2339: Property 'publicProp' does not exist on type '{}'.
21+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(57,11): error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
22+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(58,11): error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
23+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(59,11): error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
24+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(60,11): error TS2339: Property 'privateProp' does not exist on type '{}'.
25+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(62,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
26+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(63,11): error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
27+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(64,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
28+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(65,11): error TS2339: Property 'getter' does not exist on type '{}'.
29+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(67,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
30+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(68,11): error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
31+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(69,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
32+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(70,11): error TS2339: Property 'setter' does not exist on type '{}'.
33+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(72,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
34+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(73,11): error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
35+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(74,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
36+
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(75,11): error TS2339: Property 'method' does not exist on type '{}'.
2737

2838

29-
==== tests/cases/compiler/destructuringUnspreadableIntoRest.ts (26 errors) ====
39+
==== tests/cases/compiler/destructuringUnspreadableIntoRest.ts (36 errors) ====
3040
class A {
31-
constructor(public normal: string) {}
41+
constructor(
42+
public publicProp: string,
43+
private privateProp: string,
44+
) {}
3245

3346
get getter(): number {
34-
~~~~~~
35-
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
3647
return 1;
3748
}
3849

3950
set setter(_v: number) {}
40-
~~~~~~
41-
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
4251

4352
method() {
44-
const { ...rest1 } = this;
45-
const { ...rest2 } = this as A;
46-
const { normal: _1, ...rest3 } = this;
47-
const { normal: _2, ...rest4 } = this as A;
53+
const { ...rest1 } = this;
54+
const { ...rest2 } = this as A;
55+
const { publicProp: _1, ...rest3 } = this;
56+
const { publicProp: _2, ...rest4 } = this as A;
57+
58+
rest1.publicProp;
59+
rest2.publicProp;
60+
rest3.publicProp;
61+
~~~~~~~~~~
62+
!!! error TS2339: Property 'publicProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
63+
rest4.publicProp;
64+
~~~~~~~~~~
65+
!!! error TS2339: Property 'publicProp' does not exist on type '{}'.
66+
67+
rest1.privateProp;
68+
~~~~~~~~~~~
69+
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
70+
rest2.privateProp;
71+
~~~~~~~~~~~
72+
!!! error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
73+
rest3.privateProp;
74+
~~~~~~~~~~~
75+
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
76+
rest4.privateProp;
77+
~~~~~~~~~~~
78+
!!! error TS2339: Property 'privateProp' does not exist on type '{}'.
4879

4980
rest1.getter;
5081
~~~~~~
5182
!!! error TS2339: Property 'getter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
5283
rest2.getter;
5384
~~~~~~
54-
!!! error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
85+
!!! error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
5586
rest3.getter;
5687
~~~~~~
57-
!!! error TS2339: Property 'getter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
88+
!!! error TS2339: Property 'getter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
5889
rest4.getter;
5990
~~~~~~
6091
!!! error TS2339: Property 'getter' does not exist on type '{}'.
@@ -64,10 +95,10 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
6495
!!! error TS2339: Property 'setter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
6596
rest2.setter;
6697
~~~~~~
67-
!!! error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
98+
!!! error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
6899
rest3.setter;
69100
~~~~~~
70-
!!! error TS2339: Property 'setter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
101+
!!! error TS2339: Property 'setter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
71102
rest4.setter;
72103
~~~~~~
73104
!!! error TS2339: Property 'setter' does not exist on type '{}'.
@@ -77,31 +108,53 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
77108
!!! error TS2339: Property 'method' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
78109
rest2.method;
79110
~~~~~~
80-
!!! error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
111+
!!! error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
81112
rest3.method;
82113
~~~~~~
83-
!!! error TS2339: Property 'method' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
114+
!!! error TS2339: Property 'method' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
84115
rest4.method;
85116
~~~~~~
86117
!!! error TS2339: Property 'method' does not exist on type '{}'.
87118
}
88119
}
89120

90121
function destructure<T extends A>(x: T) {
91-
const { ...rest1 } = x;
92-
const { ...rest2 } = x as A;
93-
const { normal: _1, ...rest3 } = x;
94-
const { normal: _2, ...rest4 } = x as A;
122+
const { ...rest1 } = x;
123+
const { ...rest2 } = x as A;
124+
const { publicProp: _1, ...rest3 } = x;
125+
const { publicProp: _2, ...rest4 } = x as A;
126+
127+
rest1.publicProp;
128+
rest2.publicProp;
129+
rest3.publicProp;
130+
~~~~~~~~~~
131+
!!! error TS2339: Property 'publicProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
132+
rest4.publicProp;
133+
~~~~~~~~~~
134+
!!! error TS2339: Property 'publicProp' does not exist on type '{}'.
135+
136+
rest1.privateProp;
137+
~~~~~~~~~~~
138+
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
139+
rest2.privateProp;
140+
~~~~~~~~~~~
141+
!!! error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
142+
rest3.privateProp;
143+
~~~~~~~~~~~
144+
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
145+
rest4.privateProp;
146+
~~~~~~~~~~~
147+
!!! error TS2339: Property 'privateProp' does not exist on type '{}'.
95148

96149
rest1.getter;
97150
~~~~~~
98151
!!! error TS2339: Property 'getter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
99152
rest2.getter;
100153
~~~~~~
101-
!!! error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
154+
!!! error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
102155
rest3.getter;
103156
~~~~~~
104-
!!! error TS2339: Property 'getter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
157+
!!! error TS2339: Property 'getter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
105158
rest4.getter;
106159
~~~~~~
107160
!!! error TS2339: Property 'getter' does not exist on type '{}'.
@@ -111,10 +164,10 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
111164
!!! error TS2339: Property 'setter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
112165
rest2.setter;
113166
~~~~~~
114-
!!! error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
167+
!!! error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
115168
rest3.setter;
116169
~~~~~~
117-
!!! error TS2339: Property 'setter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
170+
!!! error TS2339: Property 'setter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
118171
rest4.setter;
119172
~~~~~~
120173
!!! error TS2339: Property 'setter' does not exist on type '{}'.
@@ -124,10 +177,10 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
124177
!!! error TS2339: Property 'method' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
125178
rest2.method;
126179
~~~~~~
127-
!!! error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
180+
!!! error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
128181
rest3.method;
129182
~~~~~~
130-
!!! error TS2339: Property 'method' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
183+
!!! error TS2339: Property 'method' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
131184
rest4.method;
132185
~~~~~~
133186
!!! error TS2339: Property 'method' does not exist on type '{}'.

0 commit comments

Comments
 (0)