Skip to content

Commit a1c7f1c

Browse files
authored
refactor(middleware): rename argument names like 'a', 'f' (#3032)
* refactor(middleware): rename argument name 'a' to 'arg' or 'args' * refactor(middleware): rename argument name 'f' to 'fn' * refactor(middleware/devtools.ts): rename argument name 'arg0' to 'args'
1 parent 8ced271 commit a1c7f1c

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/middleware/combine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export function combine<
1111
initialState: T,
1212
create: StateCreator<T, Mps, Mcs, U>,
1313
): StateCreator<Write<T, U>, Mps, Mcs> {
14-
return (...a) => Object.assign({}, initialState, (create as any)(...a))
14+
return (...args) => Object.assign({}, initialState, (create as any)(...args))
1515
}

src/middleware/devtools.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ type Write<T, U> = Omit<T, keyof U> & U
3030
type TakeTwo<T> = T extends { length: 0 }
3131
? [undefined, undefined]
3232
: T extends { length: 1 }
33-
? [...a0: Cast<T, unknown[]>, a1: undefined]
33+
? [...args0: Cast<T, unknown[]>, arg1: undefined]
3434
: T extends { length: 0 | 1 }
35-
? [...a0: Cast<T, unknown[]>, a1: undefined]
35+
? [...args0: Cast<T, unknown[]>, arg1: undefined]
3636
: T extends { length: 2 }
3737
? T
3838
: T extends { length: 1 | 2 }
@@ -58,13 +58,13 @@ type Action =
5858
type StoreDevtools<S> = S extends {
5959
setState: {
6060
// capture both overloads of setState
61-
(...a: infer Sa1): infer Sr1
62-
(...a: infer Sa2): infer Sr2
61+
(...args: infer Sa1): infer Sr1
62+
(...args: infer Sa2): infer Sr2
6363
}
6464
}
6565
? {
66-
setState(...a: [...a: TakeTwo<Sa1>, action?: Action]): Sr1
67-
setState(...a: [...a: TakeTwo<Sa2>, action?: Action]): Sr2
66+
setState(...args: [...args: TakeTwo<Sa1>, action?: Action]): Sr1
67+
setState(...args: [...args: TakeTwo<Sa2>, action?: Action]): Sr2
6868
}
6969
: never
7070

@@ -231,10 +231,10 @@ const devtoolsImpl: DevtoolsImpl =
231231
) {
232232
let didWarnAboutReservedActionType = false
233233
const originalDispatch = (api as any).dispatch
234-
;(api as any).dispatch = (...a: any[]) => {
234+
;(api as any).dispatch = (...args: any[]) => {
235235
if (
236236
import.meta.env?.MODE !== 'production' &&
237-
a[0].type === '__setState' &&
237+
args[0].type === '__setState' &&
238238
!didWarnAboutReservedActionType
239239
) {
240240
console.warn(
@@ -243,7 +243,7 @@ const devtoolsImpl: DevtoolsImpl =
243243
)
244244
didWarnAboutReservedActionType = true
245245
}
246-
;(originalDispatch as any)(...a)
246+
;(originalDispatch as any)(...args)
247247
}
248248
}
249249

@@ -372,7 +372,7 @@ const devtoolsImpl: DevtoolsImpl =
372372
}
373373
export const devtools = devtoolsImpl as unknown as Devtools
374374

375-
const parseJsonThen = <T>(stringified: string, f: (parsed: T) => void) => {
375+
const parseJsonThen = <T>(stringified: string, fn: (parsed: T) => void) => {
376376
let parsed: T | undefined
377377
try {
378378
parsed = JSON.parse(stringified)
@@ -382,5 +382,5 @@ const parseJsonThen = <T>(stringified: string, f: (parsed: T) => void) => {
382382
e,
383383
)
384384
}
385-
if (parsed !== undefined) f(parsed as T)
385+
if (parsed !== undefined) fn(parsed as T)
386386
}

src/middleware/immer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ type StoreImmer<S> = S extends {
4040
setState: infer SetState
4141
}
4242
? SetState extends {
43-
(...a: infer A1): infer Sr1
44-
(...a: infer A2): infer Sr2
43+
(...args: infer A1): infer Sr1
44+
(...args: infer A2): infer Sr2
4545
}
4646
? {
4747
// Ideally, we would want to infer the `nextStateOrUpdater` `T` type from the
@@ -53,14 +53,14 @@ type StoreImmer<S> = S extends {
5353
| Partial<SetStateType<A2>>
5454
| ((state: Draft<SetStateType<A2>>) => void),
5555
shouldReplace?: false,
56-
...a: SkipTwo<A1>
56+
...args: SkipTwo<A1>
5757
): Sr1
5858
setState(
5959
nextStateOrUpdater:
6060
| SetStateType<A2>
6161
| ((state: Draft<SetStateType<A2>>) => void),
6262
shouldReplace: true,
63-
...a: SkipTwo<A2>
63+
...args: SkipTwo<A2>
6464
): Sr2
6565
}
6666
: never
@@ -73,12 +73,12 @@ type ImmerImpl = <T>(
7373
const immerImpl: ImmerImpl = (initializer) => (set, get, store) => {
7474
type T = ReturnType<typeof initializer>
7575

76-
store.setState = (updater, replace, ...a) => {
76+
store.setState = (updater, replace, ...args) => {
7777
const nextState = (
7878
typeof updater === 'function' ? produce(updater as any) : updater
7979
) as ((s: T) => T) | T | Partial<T>
8080

81-
return set(nextState, replace as any, ...a)
81+
return set(nextState, replace as any, ...args)
8282
}
8383

8484
return initializer(store.setState, get, store)

src/middleware/redux.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ const reduxImpl: ReduxImpl = (reducer, initial) => (set, _get, api) => {
4545
}
4646
;(api as any).dispatchFromDevtools = true
4747

48-
return { dispatch: (...a) => (api as any).dispatch(...a), ...initial }
48+
return { dispatch: (...args) => (api as any).dispatch(...args), ...initial }
4949
}
5050
export const redux = reduxImpl as unknown as Redux

0 commit comments

Comments
 (0)