Skip to content
Myr

fix(client): `c.json()` supports `undefined`/`null` response (#1794)

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

* fix(client): `c.json()` supports `undefined`/`null` response * denoify

authored by Yusuke Wada · committed by GitHub · parent 0afb5e1 · Browse files · 3 files+20 added−4 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+20 added−4 removed

  • tests:+18 added−0 removed
  • other:+2 added−4 removed

3 files+20 added−4 removed

modified:deno_dist/types.ts+1 added-2 removed
1 unmodified line
2/* eslint-disable @typescript-eslint/no-explicit-any */3/* eslint-disable @typescript-eslint/ban-types */4import type { Context } from './context.ts'5import type { Hono } from './hono.ts'6import type { StatusCode } from './utils/http-status.ts'6import type { IntersectNonAnyTypes, UnionToIntersection } from './utils/types.ts'78////////////////////////////////////////9////// //////
1412 unmodified lines
1422 [Method: `$${Lowercase<string>}`]: {1423 input: Partial<ValidationTargets> & {1424 param?: Record<string, string>1425 }1427 output: {}1426 output: any1427 }1428 }1429}1430
126 unmodified lines
modified:src/types.test.ts+18 added
306 unmodified lines
307 type verify = Expect<Equal<Expected, Actual>>308 })309})310311describe('Support c.json(undefined)', () => {312 it('Should return a correct type', () => {313 const app = new Hono().get('/this/is/a/test', async (c) => {314 return c.json(undefined)315 })316 type Actual = ExtractSchema<typeof app>317 type Expected = {318 '/this/is/a/test': {319 $get: {320 input: {}321 output: undefined322 }323 }324 }325 type verify = Expect<Equal<Expected, Actual>>326 })327})328329describe('Test types of Handler', () => {330 type E = {331 Variables: {332 foo: number
669 unmodified lines
modified:src/types.ts+1 added-2 removed
1 unmodified line
2/* eslint-disable @typescript-eslint/no-explicit-any */3/* eslint-disable @typescript-eslint/ban-types */4import type { Context } from './context'5import type { Hono } from './hono'6import type { StatusCode } from './utils/http-status'6import type { IntersectNonAnyTypes, UnionToIntersection } from './utils/types'78////////////////////////////////////////9////// //////
1412 unmodified lines
1422 [Method: `$${Lowercase<string>}`]: {1423 input: Partial<ValidationTargets> & {1424 param?: Record<string, string>1425 }1427 output: {}1426 output: any1427 }1428 }1429}1430
126 unmodified lines