From f1c7d312a8fb921ead3e45cc0b1c999fd4e1c34a Mon Sep 17 00:00:00 2001 From: Ame_x <121654029+EdamAme-x@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:34:36 +0900 Subject: [PATCH] fix(validator-types): type Alignment with Web Standards (#3120) * fix(validator-types): type Alignment with Web Standards * fix --- src/client/client.ts | 4 ++-- src/types.ts | 7 ++++--- src/validator/validator.test.ts | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index aa329265..a5c29602 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -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 & { param?: Record }, opt?: ClientRequestOptions diff --git a/src/types.ts b/src/types.ts index 3a539911..e6f3cdeb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1927,11 +1927,12 @@ type MergeTypedResponse = T extends Promise ////// ///// //////////////////////////////////////// -export type FormValue = string | File +export type FormValue = string | Blob +export type ParsedFormValue = string | File -export type ValidationTargets = { +export type ValidationTargets = { json: any - form: Record + form: Record query: Record param: Record | Record header: Record diff --git a/src/validator/validator.test.ts b/src/validator/validator.test.ts index 2044a489..b6bf19fc 100644 --- a/src/validator/validator.test.ts +++ b/src/validator/validator.test.ts @@ -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: {