diff --git a/src/vanilla.ts b/src/vanilla.ts index 19490210..b6698b06 100644 --- a/src/vanilla.ts +++ b/src/vanilla.ts @@ -115,7 +115,8 @@ const createSnapshotDefault = ( } Object.defineProperty(snap, key, desc) }) - return Object.preventExtensions(snap) + // Object.preventExtensions is removed. ref: https://github.com/pmndrs/valtio/pull/1220 + return snap } const createHandlerDefault = ( diff --git a/tests/snapshot.test.ts b/tests/snapshot.test.ts index 53c356bd..7a20a961 100644 --- a/tests/snapshot.test.ts +++ b/tests/snapshot.test.ts @@ -24,26 +24,6 @@ describe('snapshot', () => { expect(snap1).toBe(snap2) }) - it('should make the snapshot immutable', () => { - const state = proxy<{ foo: number; bar?: string }>({ foo: 1 }) - const snap = snapshot(state) - - // Overwriting existing property - expect(() => { - ;(snap as typeof state).foo = 100 - }).toThrow() - - // Extension (adding new property) - expect(() => { - ;(snap as typeof state).bar = 'hello' - }).toThrow() - - // Note: The current implementation does not prevent property removal. - // Do not add a test for this unless we come up with an implementation that - // supports it. - // See https://github.com/pmndrs/valtio/issues/749 - }) - it('should not cause proxy-compare to copy', async () => { const state = proxy({ foo: 1 }) const snap1 = snapshot(state)