mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
recover types that are dropped in #2462
This commit is contained in:
parent
68d84b32dc
commit
8e6b914301
@ -1,4 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { devtools, redux } from 'zustand/middleware'
|
||||
import { StoreApi, createStore } from 'zustand/vanilla'
|
||||
|
||||
@ -16,12 +16,12 @@ type TupleOfEqualLength<Arr extends unknown[], T> = number extends Arr['length']
|
||||
type Connection = {
|
||||
subscribers: ((message: unknown) => void)[]
|
||||
api: {
|
||||
subscribe: any
|
||||
unsubscribe: any
|
||||
send: any
|
||||
init: any
|
||||
error: any
|
||||
dispatch?: any
|
||||
subscribe: Mock<[f: (m: unknown) => void], () => void>
|
||||
unsubscribe: Mock<any>
|
||||
send: Mock<any>
|
||||
init: Mock<any>
|
||||
error: Mock<any>
|
||||
dispatch?: Mock<any>
|
||||
}
|
||||
}
|
||||
const namedConnections = new Map<string | undefined, Connection>()
|
||||
|
||||
@ -34,7 +34,8 @@ describe('types', () => {
|
||||
})
|
||||
|
||||
describe('useShallow', () => {
|
||||
const testUseShallowSimpleCallback = vi.fn()
|
||||
const testUseShallowSimpleCallback =
|
||||
vi.fn<[{ selectorOutput: string[]; useShallowOutput: string[] }]>()
|
||||
const TestUseShallowSimple = ({
|
||||
selector,
|
||||
state,
|
||||
|
||||
@ -35,7 +35,10 @@ describe.skipIf(!React.version.startsWith('18'))(
|
||||
'ssr behavior with react 18',
|
||||
() => {
|
||||
it('should handle different states between server and client correctly', async () => {
|
||||
const { hydrateRoot }: any = await vi.importActual('react-dom/client')
|
||||
const { hydrateRoot } =
|
||||
await vi.importActual<typeof import('react-dom/client')>(
|
||||
'react-dom/client',
|
||||
)
|
||||
|
||||
const markup = renderToString(
|
||||
<React.Suspense fallback={<div>Loading...</div>}>
|
||||
@ -67,7 +70,10 @@ describe.skipIf(!React.version.startsWith('18'))(
|
||||
bears: 0,
|
||||
}))
|
||||
|
||||
const { hydrateRoot }: any = await vi.importActual('react-dom/client')
|
||||
const { hydrateRoot } =
|
||||
await vi.importActual<typeof import('react-dom/client')>(
|
||||
'react-dom/client',
|
||||
)
|
||||
|
||||
const Component = () => {
|
||||
const bears = useStore((state) => state.bears)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user