mirror of https://github.com/sveltejs/svelte
parent
0cc90a7bfe
commit
4b6e0eb4c8
@ -0,0 +1,9 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
error: {
|
||||||
|
code: 'invalid-derived-export',
|
||||||
|
message: 'Cannot export derived state',
|
||||||
|
position: [24, 66]
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,3 @@
|
|||||||
|
let count = $state(0);
|
||||||
|
|
||||||
|
export const double = $derived(count * 2);
|
@ -0,0 +1,9 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
error: {
|
||||||
|
code: 'invalid-state-export',
|
||||||
|
message: 'Cannot export state if it is reassigned',
|
||||||
|
position: [46, 86]
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,13 @@
|
|||||||
|
export const object = $state({
|
||||||
|
ok: true
|
||||||
|
});
|
||||||
|
|
||||||
|
export const primitive = $state('nope');
|
||||||
|
|
||||||
|
export function update_object() {
|
||||||
|
object.ok = !object.ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function update_primitive() {
|
||||||
|
primitive = 'yep';
|
||||||
|
}
|
Loading…
Reference in new issue