fix(types)(middleware/devtools): copy devtools option types instead of importing (#1207)

This commit is contained in:
Daishi Kato 2022-08-22 11:01:48 +09:00 committed by GitHub
parent ca0786fe47
commit e1e83e3160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,76 @@
import type { Config } from '@redux-devtools/extension'
import type {} from '@redux-devtools/extension'
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'
// Copy types to avoid import type { Config } from '@redux-devtools/extension'
// https://github.com/pmndrs/zustand/issues/1205
type Action<T = any> = {
type: T
}
type ActionCreator<A, P extends any[] = any[]> = {
(...args: P): A
}
type EnhancerOptions = {
name?: string
actionCreators?:
| ActionCreator<any>[]
| {
[key: string]: ActionCreator<any>
}
latency?: number
maxAge?: number
serialize?:
| boolean
| {
options?:
| undefined
| boolean
| {
date?: true
regex?: true
undefined?: true
error?: true
symbol?: true
map?: true
set?: true
function?: true | ((fn: (...args: any[]) => any) => string)
}
replacer?: (key: string, value: unknown) => any
reviver?: (key: string, value: unknown) => any
immutable?: any
refs?: any
}
actionSanitizer?: <A extends Action>(action: A, id: number) => A
stateSanitizer?: <S>(state: S, index: number) => S
actionsBlacklist?: string | string[]
actionsWhitelist?: string | string[]
actionsDenylist?: string | string[]
actionsAllowlist?: string | string[]
predicate?: <S, A extends Action>(state: S, action: A) => boolean
shouldRecordChanges?: boolean
pauseActionType?: string
autoPause?: boolean
shouldStartLocked?: boolean
shouldHotReload?: boolean
shouldCatchErrors?: boolean
features?: {
pause?: boolean
lock?: boolean
persist?: boolean
export?: boolean | 'custom'
import?: boolean | 'custom'
jump?: boolean
skip?: boolean
reorder?: boolean
dispatch?: boolean
test?: boolean
}
trace?: boolean | (<A extends Action>(action: A) => string)
traceLimit?: number
}
type Config = EnhancerOptions & {
type?: string
}
declare module '../vanilla' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface StoreMutators<S, A> {