pull/16015/head
Rich Harris 4 months ago
parent e91ff5b1bc
commit 4df73207b6

@ -239,7 +239,7 @@ export function EachBlock(node, context) {
const needs_derived = path.has_default_value; // to ensure that default value is only called once
const fn = b.thunk(
/** @type {Expression} */ (context.visit(path.expression?.(unwrapped), child_state))
/** @type {Expression} */ (context.visit(path.expression(unwrapped), child_state))
);
declarations.push(b.let(path.node, needs_derived ? b.call('$.derived_safe_equal', fn) : fn));

@ -49,7 +49,7 @@ export function SnippetBlock(node, context) {
const name = /** @type {Identifier} */ (path.node).name;
const needs_derived = path.has_default_value; // to ensure that default value is only called once
const fn = b.thunk(
/** @type {Expression} */ (context.visit(path.expression?.(b.maybe_call(b.id(arg_alias)))))
/** @type {Expression} */ (context.visit(path.expression(b.maybe_call(b.id(arg_alias)))))
);
declarations.push(b.let(path.node, needs_derived ? b.call('$.derived_safe_equal', fn) : fn));

@ -146,7 +146,7 @@ export function VariableDeclaration(node, context) {
declarations.push(
b.declarator(tmp, value),
...paths.map((path) => {
const value = path.expression?.(tmp);
const value = path.expression(tmp);
const binding = context.state.scope.get(/** @type {Identifier} */ (path.node).name);
return b.declarator(
path.node,
@ -237,7 +237,7 @@ export function VariableDeclaration(node, context) {
for (const path of paths) {
const name = /** @type {Identifier} */ (path.node).name;
const binding = /** @type {Binding} */ (context.state.scope.get(name));
const value = path.expression?.(b.id(tmp));
const value = path.expression(b.id(tmp));
declarations.push(
b.declarator(
path.node,
@ -309,7 +309,7 @@ function create_state_declarators(declarator, { scope, analysis }, value) {
return [
b.declarator(b.id(tmp), value),
...paths.map((path) => {
const value = path.expression?.(b.id(tmp));
const value = path.expression(b.id(tmp));
const binding = scope.get(/** @type {Identifier} */ (path.node).name);
return b.declarator(
path.node,

@ -129,7 +129,7 @@ export function VariableDeclaration(node, context) {
)
);
for (const path of paths) {
const value = path.expression?.(b.id(tmp));
const value = path.expression(b.id(tmp));
const name = /** @type {Identifier} */ (path.node).name;
const binding = /** @type {Binding} */ (context.state.scope.get(name));
const prop = b.member(b.id('$$props'), b.literal(binding.prop_alias ?? name), true);
@ -188,12 +188,12 @@ function create_state_declarators(declarator, scope, value) {
return [b.declarator(declarator.id, value)];
}
const tmp = scope.generate('tmp');
const tmp = b.id(scope.generate('tmp'));
const paths = extract_paths(declarator.id);
return [
b.declarator(b.id(tmp), value), // TODO inject declarator for opts, so we can use it below
b.declarator(tmp, value), // TODO inject declarator for opts, so we can use it below
...paths.map((path) => {
const value = path.expression?.(b.id(tmp));
const value = path.expression(tmp);
return b.declarator(path.node, value);
})
];

Loading…
Cancel
Save