fix: dont error on stores looking like runes when runes explicitly turned off (#9615)

pull/9607/head
Simon H 12 months ago committed by GitHub
parent 72d3a2a8ce
commit 78a69acfa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: dont error on stores looking like runes when runes explicitly turned off

@ -443,7 +443,7 @@ export const validation = {
};
export const validation_legacy = merge(validation, a11y_validators, {
VariableDeclarator(node) {
VariableDeclarator(node, { state }) {
if (node.init?.type !== 'CallExpression') return;
const callee = node.init.callee;
@ -454,8 +454,9 @@ export const validation_legacy = merge(validation, a11y_validators, {
return;
}
// TODO check if it's a store subscription that's called? How likely is it that someone uses a store that contains a function?
if (state.scope.get(callee.name)?.kind !== 'store_sub') {
error(node.init, 'invalid-rune-usage', callee.name);
}
},
AssignmentExpression(node, { state, path }) {
const parent = path.at(-1);

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
compileOptions: {
runes: false
}
});

@ -0,0 +1,6 @@
<script>
import { state } from './store';
const x = $state();
</script>
{x}
Loading…
Cancel
Save