mirror of https://github.com/sveltejs/svelte
The main reason for Object.freeze on `$state.frozen` is to mark a boundary for `$state` - but since that one doesn't traverse non-POJOs either, we should leave class instances etc alone, too. Since "this is a POJO and not a class instance" cannot be described in typescript, the `Readonly` modifier had to be removed from the return type.object-freeze-fix
parent
d061f2f137
commit
52414b9417
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: don't freeze non-POJOs
|
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `1`
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
class Counter {
|
||||
count = 0
|
||||
}
|
||||
const counter = $state.frozen(new Counter());
|
||||
counter.count++;
|
||||
</script>
|
||||
|
||||
{counter.count}
|
Loading…
Reference in new issue