opaque-rune
Dominic Gannaway 9 months ago
parent abe01a76e9
commit 13ca61e33e

@ -167,7 +167,7 @@ export function VariableDeclaration(node, context) {
b.arrow(
[b.id('$$fn')],
b.sequence([
b.call(b.id('$$fn'), b.member(state_id, b.id('v'))),
b.chain_call(b.id('$$fn'), b.member(state_id, b.id('v'))),
b.call('$.set', state_id, b.member(state_id, b.id('v')))
])
)

@ -98,7 +98,7 @@ export function VariableDeclaration(node, context) {
const invalidation_id = /** @type {Identifier} */ (pattern.elements[1]);
declarations.push(
b.declarator(state_id, value),
b.declarator(invalidation_id, b.arrow([b.id('$$fn')], b.call(b.id('$$fn'), state_id)))
b.declarator(invalidation_id, b.arrow([b.id('$$fn')], b.chain_call(b.id('$$fn'), state_id)))
);
continue;
}

@ -130,6 +130,17 @@ export function call(callee, ...args) {
};
}
/**
* @param {string | ESTree.Expression} callee
* @param {...(ESTree.Expression | ESTree.SpreadElement | false | undefined)} args
* @returns {ESTree.ChainExpression}
*/
export function chain_call(callee, ...args) {
const expression = /** @type {ESTree.SimpleCallExpression} */ (call(callee, ...args));
expression.optional = true;
return { type: 'ChainExpression', expression };
}
/**
* @param {string | ESTree.Expression} callee
* @param {...ESTree.Expression} args

Loading…
Cancel
Save