Skip to content

Commit

Permalink
refactor(types): prefer using import type (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Aug 22, 2022
1 parent e1e83e3 commit 0f4913c
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
ReactNode,
createElement,
createContext as reactCreateContext,
useContext,
useMemo,
useRef,
} from 'react'
import { StoreApi, useStore } from 'zustand'
import type { ReactNode } from 'react'
import { useStore } from 'zustand'
import type { StoreApi } from 'zustand'

type UseContextStore<S extends StoreApi<unknown>> = {
(): ExtractState<S>
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/combine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'

type Write<T, U> = Omit<T, keyof U> & U

Expand Down
2 changes: 1 addition & 1 deletion src/middleware/devtools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {} from '@redux-devtools/extension'
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'
import type { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'

// Copy types to avoid import type { Config } from '@redux-devtools/extension'
// https://github.com/pmndrs/zustand/issues/1205
Expand Down
6 changes: 3 additions & 3 deletions src/middleware/immer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line import/named
import { Draft, produce } from 'immer'
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'
import { produce } from 'immer'
import type { Draft } from 'immer'
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'

type Immer = <
T,
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/persist.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'
import type { StateCreator, StoreApi, StoreMutatorIdentifier } from '../vanilla'

export interface StateStorage {
getItem: (name: string) => string | null | Promise<string | null>
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/redux.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'
import { NamedSet } from './devtools'
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'
import type { NamedSet } from './devtools'

type Write<T, U> = Omit<T, keyof U> & U

Expand Down
2 changes: 1 addition & 1 deletion src/middleware/subscribeWithSelector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StateCreator, StoreMutatorIdentifier } from '../vanilla'
import type { StateCreator, StoreMutatorIdentifier } from '../vanilla'

type SubscribeWithSelector = <
T,
Expand Down
3 changes: 2 additions & 1 deletion src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { useDebugValue } from 'react'
// See: https://github.com/pmndrs/valtio/issues/452
// The following is a workaround until ESM is supported.
import useSyncExternalStoreExports from 'use-sync-external-store/shim/with-selector'
import createStore, {
import createStore from './vanilla'
import type {
Mutate,
StateCreator,
StoreApi,
Expand Down

0 comments on commit 0f4913c

Please sign in to comment.