Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
fix typescript check
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-chancetop committed Jul 24, 2023
1 parent bb3059e commit 95c3838
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/createPromiseMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
type PromiseActionMap = {
[key: string]: {
resolve: (value: any) => void;
reject: (value: any) => void;
};
};

export default function createPromiseMiddleware() {
const map = {};
const map: PromiseActionMap = {};
const middleware = () => (next: (arg0: any) => void) => (action: {type: string}) => {
const {type} = action;

Expand All @@ -24,13 +31,13 @@ export default function createPromiseMiddleware() {
fn(args);
}

function resolve(map: object, type: string, args: any) {
function resolve(map: PromiseActionMap, type: string, args: any) {
if (map[type]) {
map[type].resolve(args);
}
}

function reject(map: object, type: string, args: any) {
function reject(map: PromiseActionMap, type: string, args: any) {
if (map[type]) {
map[type].reject(args);
}
Expand Down
2 changes: 1 addition & 1 deletion src/decorator/createActionHandlerDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HandlerInterceptor<RootState extends State = State> = (handler: ActionHandl
export function createActionHandlerDecorator<
RootState extends State = State,
This extends Module<RootState, string> = Module<RootState, string>,
Fn extends (this: This, ...args: any[]) => SagaGenerator = ActionHandler
Fn extends (this: This, ...args: any[]) => SagaGenerator = ActionHandler,
>(interceptor: HandlerInterceptor<RootState>) {
return (fn: Fn, context: ClassMethodDecoratorContext<This, Fn>) => {
return function* (this: This, ...args: any[]): SagaGenerator {
Expand Down
4 changes: 2 additions & 2 deletions src/util/network.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, {Axios, AxiosError, type AxiosInterceptorManager, type AxiosRequestConfig, type AxiosResponse, type Method} from "axios";
import axios, {AxiosError, type AxiosInterceptorManager, type AxiosRequestConfig, type AxiosResponse, type InternalAxiosRequestConfig, type Method} from "axios";
import {APIException, NetworkConnectionException} from "../Exception";
import {parseWithDate} from "./json-util";

Expand Down Expand Up @@ -104,7 +104,7 @@ export function urlParams(pattern: string, params: object): string {
return url;
}

export const setAjaxRequestInterceptor: AxiosInterceptorManager<AxiosRequestConfig>["use"] = (onFulfilled?, onRejected?, options?) => {
export const setAjaxRequestInterceptor: AxiosInterceptorManager<InternalAxiosRequestConfig>["use"] = (onFulfilled, onRejected?, options?) => {
return ajaxClient.interceptors.request.use(onFulfilled, onRejected, options);
};

Expand Down

0 comments on commit 95c3838

Please sign in to comment.