|
|
|
@ -11,7 +11,7 @@ export type Context = DestructuredVariable | ComputedProperty;
|
|
|
|
|
|
|
|
|
|
|
|
interface ComputedProperty {
|
|
|
|
interface ComputedProperty {
|
|
|
|
type: 'ComputedProperty';
|
|
|
|
type: 'ComputedProperty';
|
|
|
|
property_name: string;
|
|
|
|
property_name: Identifier;
|
|
|
|
key: Expression | PrivateIdentifier;
|
|
|
|
key: Expression | PrivateIdentifier;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,8 +30,7 @@ export function unpack_destructuring({
|
|
|
|
default_modifier = (node) => node,
|
|
|
|
default_modifier = (node) => node,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props = { n: 0 }
|
|
|
|
|
|
|
|
}: {
|
|
|
|
}: {
|
|
|
|
contexts: Context[];
|
|
|
|
contexts: Context[];
|
|
|
|
node: Node;
|
|
|
|
node: Node;
|
|
|
|
@ -40,10 +39,6 @@ export function unpack_destructuring({
|
|
|
|
scope: TemplateScope;
|
|
|
|
scope: TemplateScope;
|
|
|
|
component: Component;
|
|
|
|
component: Component;
|
|
|
|
context_rest_properties: Map<string, Node>;
|
|
|
|
context_rest_properties: Map<string, Node>;
|
|
|
|
// we want to pass this by reference, as a sort of global variable, because
|
|
|
|
|
|
|
|
// if we pass this by value, we could get computed_property_# variable collisions
|
|
|
|
|
|
|
|
// when we deal with nested object destructuring
|
|
|
|
|
|
|
|
number_of_computed_props?: { n: number };
|
|
|
|
|
|
|
|
}) {
|
|
|
|
}) {
|
|
|
|
if (!node) return;
|
|
|
|
if (!node) return;
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,8 +67,7 @@ export function unpack_destructuring({
|
|
|
|
default_modifier,
|
|
|
|
default_modifier,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
context_rest_properties.set((element.argument as Identifier).name, element);
|
|
|
|
context_rest_properties.set((element.argument as Identifier).name, element);
|
|
|
|
} else if (element && element.type === 'AssignmentPattern') {
|
|
|
|
} else if (element && element.type === 'AssignmentPattern') {
|
|
|
|
@ -93,8 +87,7 @@ export function unpack_destructuring({
|
|
|
|
)}` as Node,
|
|
|
|
)}` as Node,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
unpack_destructuring({
|
|
|
|
unpack_destructuring({
|
|
|
|
@ -104,8 +97,7 @@ export function unpack_destructuring({
|
|
|
|
default_modifier,
|
|
|
|
default_modifier,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -124,8 +116,7 @@ export function unpack_destructuring({
|
|
|
|
default_modifier,
|
|
|
|
default_modifier,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
context_rest_properties.set((property.argument as Identifier).name, property);
|
|
|
|
context_rest_properties.set((property.argument as Identifier).name, property);
|
|
|
|
} else if (property.type === 'Property') {
|
|
|
|
} else if (property.type === 'Property') {
|
|
|
|
@ -136,8 +127,7 @@ export function unpack_destructuring({
|
|
|
|
|
|
|
|
|
|
|
|
if (property.computed) {
|
|
|
|
if (property.computed) {
|
|
|
|
// e.g { [computedProperty]: ... }
|
|
|
|
// e.g { [computedProperty]: ... }
|
|
|
|
const property_name = `computed_property_${number_of_computed_props.n}`;
|
|
|
|
const property_name = x`computed_property` as Identifier;
|
|
|
|
number_of_computed_props.n += 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
contexts.push({
|
|
|
|
contexts.push({
|
|
|
|
type: 'ComputedProperty',
|
|
|
|
type: 'ComputedProperty',
|
|
|
|
@ -178,8 +168,7 @@ export function unpack_destructuring({
|
|
|
|
)}` as Node,
|
|
|
|
)}` as Node,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// e.g. { property } or { property: newName }
|
|
|
|
// e.g. { property } or { property: newName }
|
|
|
|
@ -190,8 +179,7 @@ export function unpack_destructuring({
|
|
|
|
default_modifier,
|
|
|
|
default_modifier,
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
component,
|
|
|
|
component,
|
|
|
|
context_rest_properties,
|
|
|
|
context_rest_properties
|
|
|
|
number_of_computed_props
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|