fix type errors

This commit is contained in:
Pig Fang 2020-02-10 11:56:16 +08:00
parent 3dcd6bfac1
commit 576a4c442f
2 changed files with 13 additions and 5 deletions

View File

@ -129,7 +129,7 @@ const Players: React.FC = () => {
return
}
const { code, message } = await fetch.post(
const { code, message } = await fetch.post<fetch.ResponseBody>(
`/user/player/delete/${player.pid}`,
)
if (code === 0) {

View File

@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/indent */
import * as net from '../../src/scripts/net'
export { ResponseBody } from '../../src/scripts/net'
export const init = {} as typeof net.init
export const walkFetch = {} as jest.Mock<
@ -8,22 +10,28 @@ export const walkFetch = {} as jest.Mock<
Parameters<typeof net.walkFetch>
>
type FetchFn = <T = any>(url: string, data?: object) => Promise<T>
export const get = {} as jest.Mock<
ReturnType<typeof net.get>,
Parameters<typeof net.get>
>
> &
FetchFn
export const post = {} as jest.Mock<
ReturnType<typeof net.post>,
Parameters<typeof net.post>
>
> &
FetchFn
export const put = {} as jest.Mock<
ReturnType<typeof net.post>,
Parameters<typeof net.post>
>
> &
FetchFn
export const del = {} as jest.Mock<
ReturnType<typeof net.post>,
Parameters<typeof net.post>
>
> &
FetchFn