Skip to content
Myr

fix(validator): Default use to `OutputTypeExcludeResponseType` when `InputType` is unknown (#2500)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(validator): Default use to `OutputTypeExcludeResponseType` when `InputType` is unknown * denoify

authored by nagasawaryoya · committed by GitHub · parent f5104e8 · Browse files · 3 files+30 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+30 added−5 removed

  • tests:+18 added−1 removed
  • other:+12 added−4 removed

3 files+30 added−5 removed

modified:deno_dist/validator/validator.ts+6 added-2 removed
modified:src/validator/validator.test.ts+18 added-1 removed
892 unmodified lines
893 type: z.enum(['a']),894 })895 const app = new Hono()896897 app.post(897 const route = app.post(898 '/posts',899 validator('json', (value, c) => {900 const parsed = testSchema.safeParse(value)901 if (!parsed.success) {
11 unmodified lines
913 201914 )915 }916 )917918 expectTypeOf<ExtractSchema<typeof route>>().toEqualTypeOf<{919 '/posts': {920 $post: {921 input: {922 json: {923 type: 'a'924 name: string925 age: number926 }927 }928 output: {929 message: string930 }931 }932 }933 }>()934 })935})936937describe('Transform', () => {
34 unmodified lines
modified:src/validator/validator.ts+6 added-2 removed
32 unmodified lines
33 P2 extends string = P,34 V extends {35 in: {36 [K in U]: K extends 'json'37 ? InputType37 ? unknown extends InputType38 ? OutputTypeExcludeResponseType39 : InputType40 : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2] }41 }42 out: { [K in U]: OutputTypeExcludeResponseType }43 } = {44 in: {45 [K in U]: K extends 'json'44 ? InputType46 ? unknown extends InputType47 ? OutputTypeExcludeResponseType48 : InputType49 : { [K2 in keyof OutputTypeExcludeResponseType]: ValidationTargets[K][K2] }50 }51 out: { [K in U]: OutputTypeExcludeResponseType }52 },
83 unmodified lines