mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
* fix: add an inferred generic U to CreateStoreImpl * fix: add inferred generic U variables to both Devtools and DevtoolsImpl * test: add tests for issue #2700 * revert impl types * code styling --------- Co-authored-by: daishi <daishi@axlight.com>
This commit is contained in:
parent
5ed67ec1a9
commit
af7ff21190
@ -79,8 +79,9 @@ type Devtools = <
|
||||
T,
|
||||
Mps extends [StoreMutatorIdentifier, unknown][] = [],
|
||||
Mcs extends [StoreMutatorIdentifier, unknown][] = [],
|
||||
U = T,
|
||||
>(
|
||||
initializer: StateCreator<T, [...Mps, ['zustand/devtools', never]], Mcs>,
|
||||
initializer: StateCreator<T, [...Mps, ['zustand/devtools', never]], Mcs, U>,
|
||||
devtoolsOptions?: DevtoolsOptions,
|
||||
) => StateCreator<T, Mps, [['zustand/devtools', never], ...Mcs]>
|
||||
|
||||
|
||||
@ -177,6 +177,24 @@ describe('counter state spec (single middleware)', () => {
|
||||
expect(testSubtyping).toBeDefined()
|
||||
})
|
||||
|
||||
it('devtools #2700', () => {
|
||||
type TableStore = {
|
||||
table: string
|
||||
}
|
||||
const useStoreA = create<TableStore | null>()(
|
||||
devtools((_set) => null, { name: 'table-storage' }),
|
||||
)
|
||||
expect(useStoreA).toBeDefined()
|
||||
const useStoreB = create<TableStore | null>()(
|
||||
devtools(() => null, { name: 'table-storage' }),
|
||||
)
|
||||
expect(useStoreB).toBeDefined()
|
||||
const useStoreC = create<TableStore | null>()((_set) => null)
|
||||
expect(useStoreC).toBeDefined()
|
||||
const useStoreD = create<TableStore | null>()(() => null)
|
||||
expect(useStoreD).toBeDefined()
|
||||
})
|
||||
|
||||
it('subscribeWithSelector', () => {
|
||||
const useBoundStore = create<CounterState>()(
|
||||
subscribeWithSelector((set, get) => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user