@@ -11,7 +11,7 @@ export type Context = DestructuredVariable | ComputedProperty;
11
11
12
12
interface ComputedProperty {
13
13
type : 'ComputedProperty' ;
14
- property_name : string ;
14
+ property_name : Identifier ;
15
15
key : Expression | PrivateIdentifier ;
16
16
}
17
17
@@ -30,8 +30,7 @@ export function unpack_destructuring({
30
30
default_modifier = ( node ) => node ,
31
31
scope,
32
32
component,
33
- context_rest_properties,
34
- number_of_computed_props = { n : 0 }
33
+ context_rest_properties
35
34
} : {
36
35
contexts : Context [ ] ;
37
36
node : Node ;
@@ -40,10 +39,6 @@ export function unpack_destructuring({
40
39
scope : TemplateScope ;
41
40
component : Component ;
42
41
context_rest_properties : Map < string , Node > ;
43
- // we want to pass this by reference, as a sort of global variable, because
44
- // if we pass this by value, we could get computed_property_# variable collisions
45
- // when we deal with nested object destructuring
46
- number_of_computed_props ?: { n : number } ;
47
42
} ) {
48
43
if ( ! node ) return ;
49
44
@@ -72,8 +67,7 @@ export function unpack_destructuring({
72
67
default_modifier,
73
68
scope,
74
69
component,
75
- context_rest_properties,
76
- number_of_computed_props
70
+ context_rest_properties
77
71
} ) ;
78
72
context_rest_properties . set ( ( element . argument as Identifier ) . name , element ) ;
79
73
} else if ( element && element . type === 'AssignmentPattern' ) {
@@ -93,8 +87,7 @@ export function unpack_destructuring({
93
87
) } ` as Node ,
94
88
scope,
95
89
component,
96
- context_rest_properties,
97
- number_of_computed_props
90
+ context_rest_properties
98
91
} ) ;
99
92
} else {
100
93
unpack_destructuring ( {
@@ -104,8 +97,7 @@ export function unpack_destructuring({
104
97
default_modifier,
105
98
scope,
106
99
component,
107
- context_rest_properties,
108
- number_of_computed_props
100
+ context_rest_properties
109
101
} ) ;
110
102
}
111
103
} ) ;
@@ -124,8 +116,7 @@ export function unpack_destructuring({
124
116
default_modifier,
125
117
scope,
126
118
component,
127
- context_rest_properties,
128
- number_of_computed_props
119
+ context_rest_properties
129
120
} ) ;
130
121
context_rest_properties . set ( ( property . argument as Identifier ) . name , property ) ;
131
122
} else if ( property . type === 'Property' ) {
@@ -136,8 +127,7 @@ export function unpack_destructuring({
136
127
137
128
if ( property . computed ) {
138
129
// e.g { [computedProperty]: ... }
139
- const property_name = `computed_property_${ number_of_computed_props . n } ` ;
140
- number_of_computed_props . n += 1 ;
130
+ const property_name = component . get_unique_name ( 'computed_property' ) ;
141
131
142
132
contexts . push ( {
143
133
type : 'ComputedProperty' ,
@@ -178,8 +168,7 @@ export function unpack_destructuring({
178
168
) } ` as Node ,
179
169
scope,
180
170
component,
181
- context_rest_properties,
182
- number_of_computed_props
171
+ context_rest_properties
183
172
} ) ;
184
173
} else {
185
174
// e.g. { property } or { property: newName }
@@ -190,8 +179,7 @@ export function unpack_destructuring({
190
179
default_modifier,
191
180
scope,
192
181
component,
193
- context_rest_properties,
194
- number_of_computed_props
182
+ context_rest_properties
195
183
} ) ;
196
184
}
197
185
}
0 commit comments