mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
fix(validator-types): type Alignment with Web Standards (#3120)
* fix(validator-types): type Alignment with Web Standards * fix
This commit is contained in:
parent
ec58511247
commit
f1c7d312a8
@ -1,5 +1,5 @@
|
||||
import type { Hono } from '../hono'
|
||||
import type { ValidationTargets } from '../types'
|
||||
import type { FormValue, ValidationTargets } from '../types'
|
||||
import { serialize } from '../utils/cookie'
|
||||
import type { UnionToIntersection } from '../utils/types'
|
||||
import type { Callback, Client, ClientRequestOptions } from './types'
|
||||
@ -42,7 +42,7 @@ class ClientRequestImpl {
|
||||
this.method = method
|
||||
}
|
||||
fetch = async (
|
||||
args?: ValidationTargets & {
|
||||
args?: ValidationTargets<FormValue> & {
|
||||
param?: Record<string, string>
|
||||
},
|
||||
opt?: ClientRequestOptions
|
||||
|
@ -1927,11 +1927,12 @@ type MergeTypedResponse<T> = T extends Promise<infer T2>
|
||||
////// /////
|
||||
////////////////////////////////////////
|
||||
|
||||
export type FormValue = string | File
|
||||
export type FormValue = string | Blob
|
||||
export type ParsedFormValue = string | File
|
||||
|
||||
export type ValidationTargets = {
|
||||
export type ValidationTargets<T extends FormValue = ParsedFormValue> = {
|
||||
json: any
|
||||
form: Record<string, FormValue | FormValue[]>
|
||||
form: Record<string, T | T[]>
|
||||
query: Record<string, string | string[]>
|
||||
param: Record<string, string> | Record<string, string | undefined>
|
||||
header: Record<string, string>
|
||||
|
@ -8,6 +8,7 @@ import type {
|
||||
ExtractSchema,
|
||||
FormValue,
|
||||
MiddlewareHandler,
|
||||
ParsedFormValue,
|
||||
ValidationTargets,
|
||||
} from '../types'
|
||||
import type { StatusCode } from '../utils/http-status'
|
||||
@ -749,7 +750,7 @@ it('With path parameters', () => {
|
||||
$put: {
|
||||
input: {
|
||||
form: {
|
||||
title: FormValue | FormValue[]
|
||||
title: ParsedFormValue | ParsedFormValue[]
|
||||
}
|
||||
} & {
|
||||
param: {
|
||||
@ -795,7 +796,7 @@ it('`on`', () => {
|
||||
$purge: {
|
||||
input: {
|
||||
form: {
|
||||
tag: FormValue | FormValue[]
|
||||
tag: ParsedFormValue | ParsedFormValue[]
|
||||
}
|
||||
} & {
|
||||
query: {
|
||||
|
Loading…
Reference in New Issue
Block a user