mirror of
https://github.com/vercel/commerce.git
synced 2025-03-14 22:42:33 +00:00
Added proper type for fetch input
This commit is contained in:
parent
479b30ba5f
commit
016be86d9a
@ -45,7 +45,11 @@ export type HookFetcherOptions = {
|
||||
method?: string
|
||||
}
|
||||
|
||||
export type HookInput = [string, string | number | boolean | undefined][]
|
||||
export type HookInputValue = string | number | boolean | undefined
|
||||
|
||||
export type HookInput = [string, HookInputValue][]
|
||||
|
||||
export type HookFetchInput = { [k: string]: HookInputValue }
|
||||
|
||||
export type HookHandler<
|
||||
// Data obj returned by the hook and fetch operation
|
||||
@ -53,7 +57,7 @@ export type HookHandler<
|
||||
// Input expected by the hook
|
||||
Input = [...any],
|
||||
// Input expected before doing a fetch operation
|
||||
FetchInput = unknown,
|
||||
FetchInput extends HookFetchInput = never,
|
||||
// Data returned by the API after a fetch operation
|
||||
Result = any,
|
||||
// Body expected by the API endpoint
|
||||
|
@ -1,5 +1,11 @@
|
||||
import useSWR, { responseInterface } from 'swr'
|
||||
import type { HookHandler, HookInput, PickRequired, Fetcher } from './types'
|
||||
import type {
|
||||
HookHandler,
|
||||
HookInput,
|
||||
HookFetchInput,
|
||||
PickRequired,
|
||||
Fetcher,
|
||||
} from './types'
|
||||
import defineProperty from './define-property'
|
||||
import { CommerceError } from './errors'
|
||||
|
||||
@ -10,7 +16,7 @@ export type ResponseState<Result> = responseInterface<Result, CommerceError> & {
|
||||
export type UseData = <
|
||||
Data = any,
|
||||
Input = [...any],
|
||||
FetchInput = unknown,
|
||||
FetchInput extends HookFetchInput = never,
|
||||
Result = any,
|
||||
Body = any
|
||||
>(
|
||||
|
Loading…
x
Reference in New Issue
Block a user