Skip to content

Commit

Permalink
Reformat (only the files changed in the previous commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 committed Dec 10, 2022
1 parent f401932 commit e33dfb7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
5 changes: 2 additions & 3 deletions packages/toolkit/src/query/core/buildThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import type {
MutationDefinition,
QueryArgFrom,
QueryDefinition,
ResultTypeFrom} from '../endpointDefinitions';
import {
isQueryDefinition
ResultTypeFrom,
} from '../endpointDefinitions'
import { isQueryDefinition } from '../endpointDefinitions'
import { calculateProvidedBy } from '../endpointDefinitions'
import type { AsyncThunkPayloadCreator, Draft } from '@reduxjs/toolkit'
import {
Expand Down
7 changes: 2 additions & 5 deletions packages/toolkit/src/query/createApi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import type { Api, ApiContext, Module, ModuleName } from './apiTypes'
import type { CombinedState } from './core/apiState'
import type { BaseQueryArg, BaseQueryFn } from './baseQueryTypes'
import type {
SerializeQueryArgs} from './defaultSerializeQueryArgs';
import {
defaultSerializeQueryArgs
} from './defaultSerializeQueryArgs'
import type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
import { defaultSerializeQueryArgs } from './defaultSerializeQueryArgs'
import type {
EndpointBuilder,
EndpointDefinitions,
Expand Down
8 changes: 2 additions & 6 deletions packages/toolkit/src/query/tests/buildHooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ import {
import { server } from './mocks/server'
import type { AnyAction } from 'redux'
import type { SubscriptionOptions } from '@reduxjs/toolkit/dist/query/core/apiState'
import type {
SerializedError} from '@reduxjs/toolkit';
import {
createListenerMiddleware,
configureStore,
} from '@reduxjs/toolkit'
import type { SerializedError } from '@reduxjs/toolkit'
import { createListenerMiddleware, configureStore } from '@reduxjs/toolkit'
import { renderHook } from '@testing-library/react'
import { delay } from '../../utils'

Expand Down
8 changes: 2 additions & 6 deletions packages/toolkit/src/tests/autoBatchEnhancer.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { configureStore } from '../configureStore'
import { createSlice } from '../createSlice'
import type {
AutoBatchOptions} from '../autoBatchEnhancer';
import {
autoBatchEnhancer,
prepareAutoBatched
} from '../autoBatchEnhancer'
import type { AutoBatchOptions } from '../autoBatchEnhancer'
import { autoBatchEnhancer, prepareAutoBatched } from '../autoBatchEnhancer'
import { delay } from '../utils'
import { debounce } from 'lodash'

Expand Down
45 changes: 28 additions & 17 deletions packages/toolkit/src/tests/configureStore.typetest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import type {
Reducer,
Store,
Action,
StoreEnhancer
StoreEnhancer,
} from 'redux'
import { applyMiddleware } from 'redux'
import type { PayloadAction ,
ConfigureStoreOptions} from '@reduxjs/toolkit'
import type { PayloadAction, ConfigureStoreOptions } from '@reduxjs/toolkit'
import {
configureStore,
getDefaultMiddleware,
createSlice
createSlice,
} from '@reduxjs/toolkit'
import type { ThunkMiddleware, ThunkAction, ThunkDispatch } from 'redux-thunk'
import thunk from 'redux-thunk'
Expand Down Expand Up @@ -144,10 +143,12 @@ const _anyMiddleware: any = () => () => () => {}
{
const store = configureStore({
reducer: () => 0,
enhancers: [applyMiddleware(() => next => next)]
enhancers: [applyMiddleware(() => (next) => next)],
})

expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(store.dispatch)
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(
store.dispatch
)
}

configureStore({
Expand All @@ -159,7 +160,7 @@ const _anyMiddleware: any = () => () => () => {}
{
type SomePropertyStoreEnhancer = StoreEnhancer<{ someProperty: string }>

const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = next => {
const somePropertyStoreEnhancer: SomePropertyStoreEnhancer = (next) => {
return (reducer, preloadedState) => {
return {
...next(reducer, preloadedState),
Expand All @@ -168,9 +169,13 @@ const _anyMiddleware: any = () => () => () => {}
}
}

type AnotherPropertyStoreEnhancer = StoreEnhancer<{ anotherProperty: number }>
type AnotherPropertyStoreEnhancer = StoreEnhancer<{
anotherProperty: number
}>

const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = next => {
const anotherPropertyStoreEnhancer: AnotherPropertyStoreEnhancer = (
next
) => {
return (reducer, preloadedState) => {
return {
...next(reducer, preloadedState),
Expand All @@ -184,7 +189,9 @@ const _anyMiddleware: any = () => () => () => {}
enhancers: [somePropertyStoreEnhancer, anotherPropertyStoreEnhancer],
})

expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(store.dispatch)
expectType<Dispatch & ThunkDispatch<number, undefined, AnyAction>>(
store.dispatch
)
expectType<string>(store.someProperty)
expectType<number>(store.anotherProperty)
}
Expand Down Expand Up @@ -348,7 +355,9 @@ const _anyMiddleware: any = () => () => () => {}
{
const store = configureStore({
reducer: reducerA,
middleware: [] as any as readonly [Middleware<(a: StateA) => boolean, StateA>],
middleware: [] as any as readonly [
Middleware<(a: StateA) => boolean, StateA>
],
})
const result: boolean = store.dispatch(5)
// @ts-expect-error
Expand Down Expand Up @@ -532,21 +541,23 @@ const _anyMiddleware: any = () => () => () => {}
initialState: null as any,
reducers: {
set(state) {
return state;
return state
},
},
});
})

function configureMyStore<S>(options: Omit<ConfigureStoreOptions<S>, 'reducer'>) {
function configureMyStore<S>(
options: Omit<ConfigureStoreOptions<S>, 'reducer'>
) {
return configureStore({
...options,
reducer: someSlice.reducer,
});
})
}

const store = configureMyStore({});
const store = configureMyStore({})

expectType<Function>(store.dispatch);
expectType<Function>(store.dispatch)
}

{
Expand Down

0 comments on commit e33dfb7

Please sign in to comment.