0
0
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:
Ame_x 2024-07-11 16:34:36 +09:00 committed by GitHub
parent ec58511247
commit f1c7d312a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -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>

View File

@ -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: {