mirror of https://github.com/sveltejs/svelte
fix: extend derived/state validation error to indirect exports (#14039)
Closes #14029pull/14041/head
parent
1434f48f7c
commit
8a2c97a7b8
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: extend derived/state validation error to indirect exports
|
@ -0,0 +1,10 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'derived_invalid_export',
|
||||
message:
|
||||
'Cannot export derived state from a module. To expose the current derived value, export a function returning its value',
|
||||
position: [70, 76]
|
||||
}
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
let count = $state(0);
|
||||
|
||||
const double = $derived(count * 2);
|
||||
|
||||
export { double };
|
@ -0,0 +1,10 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'state_invalid_export',
|
||||
message:
|
||||
"Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties",
|
||||
position: [211, 220]
|
||||
}
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
const object = $state({
|
||||
ok: true
|
||||
});
|
||||
|
||||
let primitive = $state('nope');
|
||||
|
||||
export function update_object() {
|
||||
object.ok = !object.ok;
|
||||
}
|
||||
|
||||
export function update_primitive() {
|
||||
primitive = 'yep';
|
||||
}
|
||||
|
||||
export { object, primitive };
|
Loading…
Reference in new issue