mirror of https://github.com/sveltejs/svelte
fix: remove overzealous `reactive_declaration_non_reactive_property` warning (#14663)
fixes #14532 This removes the `reactive_declaration_non_reactive_property` warning altogether. The first version caused many false positives at compile time. The refined runtime version (introduced in #14192) was hoped to fix this, but it turns out we now get loads of false positives at runtime.pull/14679/head
parent
ea6fd95332
commit
68d266e0f8
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: remove overzealous `reactive_declaration_non_reactive_property` warning
|
@ -1,26 +0,0 @@
|
|||||||
import { flushSync } from 'svelte';
|
|
||||||
import { test } from '../../test';
|
|
||||||
|
|
||||||
export default test({
|
|
||||||
compileOptions: {
|
|
||||||
dev: true
|
|
||||||
},
|
|
||||||
|
|
||||||
html: '<p>42</p><p>42</p><button>update</button><button>reset</button>',
|
|
||||||
|
|
||||||
test({ assert, target }) {
|
|
||||||
const [update, reset] = target.querySelectorAll('button');
|
|
||||||
flushSync(() => update.click());
|
|
||||||
|
|
||||||
assert.htmlEqual(
|
|
||||||
target.innerHTML,
|
|
||||||
'<p>42</p><p>42</p><button>update</button><button>reset</button>'
|
|
||||||
);
|
|
||||||
|
|
||||||
flushSync(() => reset.click());
|
|
||||||
},
|
|
||||||
|
|
||||||
warnings: [
|
|
||||||
'A `$:` statement (main.svelte:4:1) read reactive state that was not visible to the compiler. Updates to this state will not cause the statement to re-run. The behaviour of this code will change if you migrate it to runes mode'
|
|
||||||
]
|
|
||||||
});
|
|
@ -1,11 +0,0 @@
|
|||||||
export const obj = $state({
|
|
||||||
prop: 42
|
|
||||||
});
|
|
||||||
|
|
||||||
export function update() {
|
|
||||||
obj.prop += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function reset() {
|
|
||||||
obj.prop = 42;
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<script>
|
|
||||||
import { obj, update, reset } from './data.svelte.js';
|
|
||||||
|
|
||||||
$: a = obj.prop;
|
|
||||||
|
|
||||||
// svelte-ignore reactive_declaration_non_reactive_property
|
|
||||||
$: b = obj.prop;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>{a}</p>
|
|
||||||
<p>{b}</p>
|
|
||||||
<button on:click={update}>update</button>
|
|
||||||
<button on:click={reset}>reset</button>
|
|
Loading…
Reference in new issue