recover types that are dropped in #2462

This commit is contained in:
daishi 2024-04-06 20:58:47 +09:00
parent 68d84b32dc
commit 8e6b914301
3 changed files with 17 additions and 10 deletions

View File

@ -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>()

View File

@ -34,7 +34,8 @@ describe('types', () => {
})
describe('useShallow', () => {
const testUseShallowSimpleCallback = vi.fn()
const testUseShallowSimpleCallback =
vi.fn<[{ selectorOutput: string[]; useShallowOutput: string[] }]>()
const TestUseShallowSimple = ({
selector,
state,

View File

@ -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)