Skip to content

Commit fae36c9

Browse files
authored
[v2] export Snapshot type (#856)
1 parent 4162033 commit fae36c9

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

src/react.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
isChanged,
1313
} from 'proxy-compare'
1414
import { snapshot, subscribe } from './vanilla.ts'
15-
import type { INTERNAL_Snapshot as Snapshot } from './vanilla.ts'
15+
import type { Snapshot } from './vanilla.ts'
1616

1717
const useAffectedDebugValue = (
1818
state: object,

src/vanilla.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,14 @@ type SnapshotIgnore =
2828
| AnyFunction
2929
| Primitive
3030

31-
type Snapshot<T> = T extends { $$valtioSnapshot: infer S }
31+
export type Snapshot<T> = T extends { $$valtioSnapshot: infer S }
3232
? S
3333
: T extends SnapshotIgnore
3434
? T
3535
: T extends object
3636
? { readonly [K in keyof T]: Snapshot<T[K]> }
3737
: T
3838

39-
/**
40-
* This is not a public API.
41-
* It can be changed without any notice.
42-
*/
43-
export type INTERNAL_Snapshot<T> = Snapshot<T>
44-
4539
type CreateSnapshot = <T extends object>(target: T, version: number) => T
4640

4741
type RemoveListener = () => void

tests/snapshot.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createProxy, getUntracked } from 'proxy-compare'
22
import { TypeEqual, expectType } from 'ts-expect'
33
import { describe, expect, it } from 'vitest'
4-
import { INTERNAL_Snapshot as Snapshot, proxy, snapshot } from 'valtio'
4+
import { Snapshot, proxy, snapshot } from 'valtio'
55

66
it('should return correct snapshots without subscribe', async () => {
77
const child = proxy({ count: 0 })

0 commit comments

Comments
 (0)