Skip to content

Commit 87075d1

Browse files
authored
improve typing for unbound functions (#1263)
This updates some function declarations to satisfy the `@typescript-eslint/unbound-method` ESLint rule.
1 parent 642be78 commit 87075d1

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/toolkit/src/createAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export type _ActionCreatorWithPreparedPayload<
8383
*/
8484
interface BaseActionCreator<P, T extends string, M = never, E = never> {
8585
type: T
86-
match(action: Action<unknown>): action is PayloadAction<P, T, M, E>
86+
match: (action: Action<unknown>) => action is PayloadAction<P, T, M, E>
8787
}
8888

8989
/**

packages/toolkit/src/createAsyncThunk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ export type AsyncThunkAction<
235235
| ReturnType<AsyncThunkFulfilledActionCreator<Returned, ThunkArg>>
236236
| ReturnType<AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>>
237237
> & {
238-
abort(reason?: string): void
238+
abort: (reason?: string) => void
239239
requestId: string
240240
arg: ThunkArg
241-
unwrap(): Promise<Returned>
241+
unwrap: () => Promise<Returned>
242242
}
243243

244244
type AsyncThunkActionCreator<

packages/toolkit/src/matchers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ export type UnknownAsyncThunkAction =
359359
| UnknownAsyncThunkFulfilledAction
360360

361361
export type AnyAsyncThunk = {
362-
pending: { match(action: any): action is any }
363-
fulfilled: { match(action: any): action is any }
364-
rejected: { match(action: any): action is any }
362+
pending: { match: (action: any) => action is any }
363+
fulfilled: { match: (action: any) => action is any }
364+
rejected: { match: (action: any) => action is any }
365365
}
366366

367367
export type ActionsFromAsyncThunk<T extends AnyAsyncThunk> =

packages/toolkit/src/tsHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export type NoInfer<T> = [T][T extends any ? 0 : never]
102102
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>
103103

104104
export interface HasMatchFunction<T> {
105-
match(v: any): v is T
105+
match: (v: any) => v is T
106106
}
107107

108108
export const hasMatchFunction = <T>(

0 commit comments

Comments
 (0)