add tests, add to server

pull/15589/head
ComputerGuy 6 months ago
parent f98b73e6f5
commit 4d11b5656e

@ -1,4 +1,4 @@
/** @import { CallExpression, Expression } from 'estree' */ /** @import { ArrowFunctionExpression, CallExpression, Expression } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import { is_ignored } from '../../../../state.js'; import { is_ignored } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '../../../../utils/builders.js';
@ -37,5 +37,17 @@ export function CallExpression(node, context) {
return transform_inspect_rune(node, context); return transform_inspect_rune(node, context);
} }
if (
rune === '$state' &&
(context.path.at(-1)?.type === 'ReturnStatement' ||
(context.path.at(-1)?.type === 'ArrowFunctionExpression' &&
/** @type {ArrowFunctionExpression} */ (context.path.at(-1)).body === node))
) {
if (node.arguments[0]) {
return context.visit(node.arguments[0]);
}
return b.void0;
}
context.next(); context.next();
} }

@ -0,0 +1,14 @@
/* index.svelte.js generated by Svelte VERSION */
import * as $ from 'svelte/internal/client';
export default function proxy(object) {
return $.proxy(object);
}
export function createCounter() {
let count = $.state(0);
$.update(count);
}
export const proxy_in_arrow = (object) => $.proxy(object);

@ -0,0 +1,14 @@
/* index.svelte.js generated by Svelte VERSION */
import * as $ from 'svelte/internal/server';
export default function proxy(object) {
return object;
}
export function createCounter() {
let count = 0;
count++;
}
export const proxy_in_arrow = (object) => object;

@ -0,0 +1,8 @@
export default function proxy(object) {
return $state(object);
}
export function createCounter() {
let count = $state(0);
count++;
}
export const proxy_in_arrow = object => $state(object);
Loading…
Cancel
Save