mirror of https://github.com/sveltejs/svelte
fix: throw error when auto-subscribed store variable shadow by local variable (#11170)
parent
f90639d89c
commit
9b67ee18eb
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: throw error when auto-subscribed store variable shadow by local variable
|
@ -0,0 +1,9 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'illegal-store-subscription',
|
||||
message: 'Cannot subscribe to stores that are not declared at the top level of the component',
|
||||
position: [142, 147]
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store';
|
||||
const user = writable(0);
|
||||
const users = [];
|
||||
$: selected = users.find(user => user.id == $user);
|
||||
|
||||
$: console.log($user);
|
||||
</script>
|
@ -0,0 +1,9 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'illegal-store-subscription',
|
||||
message: 'Cannot subscribe to stores that are not declared at the top level of the component',
|
||||
position: [167, 172]
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store';
|
||||
const user = writable(0);
|
||||
const users = [];
|
||||
|
||||
$: console.log($user);
|
||||
$: selected = users.find(user => user.id == $user);
|
||||
</script>
|
Loading…
Reference in new issue