Merge branch 'main' into next
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Yusuke Wada · committed by Yusuke Wada · parents 9a6e52d, 2d01359 · Browse files · 6 files·+39 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+39 added−10 removed
- tests:+25 added−3 removed
- other:+14 added−7 removed
Provenance
- Commit
9987b59- Tree
ceaebbb- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
Yusuke Wada <yusuke@kamawada.com>- Parent 1
9a6e52d- Parent 2
2d01359
6 files changed+39 added−10 removed
modified:src/client/client.ts+2 added-2 removed
1 import type { Hono } from '../hono'2-import type { ValidationTargets } from '../types'2+import type { FormValue, ValidationTargets } from '../types'3 import { serialize } from '../utils/cookie'4 import type { UnionToIntersection } from '../utils/types'5 import type { Callback, Client, ClientRequestOptions } from './types'6 import {34 unmodified lines41 this.url = url42 this.method = method43 }44 fetch = async (45- args?: ValidationTargets & {45+ args?: ValidationTargets<FormValue> & {46 param?: Record<string, string>47 },48 opt?: ClientRequestOptions49 ) => {151 unmodified linesmodified:src/helper/factory/index.ts+5 added-1 removed
239 unmodified lines240 export const createFactory = <E extends Env = any, P extends string = any>(init?: {241 initApp?: InitApp<E>242 }): Factory<E, P> => new Factory<E, P>(init)243 244-export const createMiddleware = <E extends Env = any, P extends string = any, I extends Input = {}>(244+export const createMiddleware = <245+ E extends Env = any,246+ P extends string = string,247+ I extends Input = {}248+>(249 middleware: MiddlewareHandler<E, P, I>250 ): MiddlewareHandler<E, P, I> => createFactory<E, P>().createMiddleware<I>(middleware)modified:src/jsx/intrinsic-elements.ts+1 added-1 removed
616 unmodified lines617 align?: 'left' | 'center' | 'right' | 'justify' | 'char' | undefined618 colspan?: number | undefined619 headers?: string | undefined620 rowspan?: number | undefined621- scope?: string | undefined621+ scope?: 'row' | 'col' | 'rowgroup' | 'colgroup' | string | undefined622 abbr?: string | undefined623 }624 625 interface TimeHTMLAttributes extends HTMLAttributes {142 unmodified linesmodified:src/validator/validator.test.ts+10 added-3 removed
1 unmodified line2 import type { ZodSchema } from 'zod'3 import { z } from 'zod'4 import { Hono } from '../hono'5 import { HTTPException } from '../http-exception'6-import type { ErrorHandler, ExtractSchema, MiddlewareHandler, ValidationTargets } from '../types'6+import type {7+ ErrorHandler,8+ ExtractSchema,9+ FormValue,10+ MiddlewareHandler,11+ ParsedFormValue,12+ ValidationTargets,13+} from '../types'14 import type { StatusCode } from '../utils/http-status'15 import type { Equal, Expect } from '../utils/types'16 import type { ValidationFunction } from './validator'17 import { validator } from './validator'731 unmodified lines749 '/posts/:id': {750 $put: {751 input: {752 form: {746- title: string | File753+ title: ParsedFormValue | ParsedFormValue[]754 }755 } & {756 param: {757 id: string37 unmodified lines795 '/purge': {796 $purge: {797 input: {798 form: {792- tag: string | File799+ tag: ParsedFormValue | ParsedFormValue[]800 }801 } & {802 query: {803 q: string | string[]272 unmodified linesmodified:src/types.test.ts+15 added
2223 unmodified lines2224 return c.json(0)2225 })2226 })2227 })2228+2229+// https://github.com/honojs/hono/issues/31222230+describe('Returning type from `app.use(path, mw)`', () => {2231+ const mw = createMiddleware(async (c, next) => {2232+ await next()2233+ })2234+ it('Should not mark `*` as never', () => {2235+ const app = new Hono().use('*', mw)2236+ type Actual = ExtractSchema<typeof app>2237+ type Expected = {2238+ '*': {}2239+ }2240+ type verify = Expect<Equal<Expected, Actual>>2241+ })2242+})modified:src/types.ts+6 added-3 removed
1802 unmodified lines1803 }1804 }1805 1806 type ChangePathOfSchema<S extends Schema, Path extends string> = keyof S extends never1807- ? { [K in Path]: never }1807+ ? { [K in Path]: {} }1808 : { [K in keyof S as Path]: S[K] }1809 1810 export type Endpoint = {1811 input: Partial<ValidationTargets>114 unmodified lines1926 ////// ValidationTargets /////1927 ////// /////1928 ////////////////////////////////////////1929 1930-export type ValidationTargets = {1930+export type FormValue = string | Blob1931+export type ParsedFormValue = string | File1932+1933+export type ValidationTargets<T extends FormValue = ParsedFormValue> = {1934 json: any1932- form: Record<string, string | File>1935+ form: Record<string, T | T[]>1936 query: Record<string, string | string[]>1937 param: Record<string, string> | Record<string, string | undefined>1938 header: Record<string, string>1939 cookie: Record<string, string>70 unmodified lines