Skip to content
Myr

fix(`jsonT`): remove overloads from `JSONTRespond` (#1208)

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

* fix(`jsonT`): remove overloads from `JSONTRespond` * denoify * update tests

authored by Yusuke Wada · committed by GitHub · parent bae5419 · Browse files · 5 files+5 added−41 removed
This commit

State

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

Diff stats

5 files+5 added−41 removed

  • tests:+5 added−5 removed
  • other:+0 added−36 removed

5 files+5 added−41 removed

modified:deno_dist/context.ts-18 removed
43 unmodified lines
44}4546interface JSONTRespond {47 <T>(48 object: T extends JSONValue ? T : JSONValue,49 status?: StatusCode,50 headers?: HeaderRecord51 ): TypedResponse<52 InterfaceToType<T> extends JSONValue53 ? JSONValue extends InterfaceToType<T>54 ? never55 : T56 : never57 >58 <T>(48 object: InterfaceToType<T> extends JSONValue ? T : JSONValue,49 status?: StatusCode,50 headers?: HeaderRecord51 ): TypedResponse<
2 unmodified lines
54 ? never55 : T56 : never57 >69 <T>(object: T extends JSONValue ? T : JSONValue, init?: ResponseInit): TypedResponse<70 InterfaceToType<T> extends JSONValue71 ? JSONValue extends InterfaceToType<T>72 ? never73 : T74 : never75 >58 <T>(59 object: InterfaceToType<T> extends JSONValue ? T : JSONValue,60 init?: ResponseInit61 ): TypedResponse<
357 unmodified lines
modified:src/client/client.test.ts+3 added-3 removed
285 unmodified lines
286 const client = hc<AppType>('/')287 const req = client.index.$get288289 type Actual = InferResponseType<typeof req>290 type Expected = { ok: true }290 type Expected = { ok: boolean }291 type verify = Expect<Equal<Expected, Actual>>292 })293294 it('Should infer request type the type correctly', () => {
48 unmodified lines
343 type AppType = typeof app344 const client = hc<AppType>('http://localhost')345 const res = await client.api.search.$get()346 const data = await res.json()347 type verify = Expect<Equal<true, typeof data.ok>>347 type verify = Expect<Equal<boolean, typeof data.ok>>348 expect(data.ok).toBe(true)349 })350351 it('Should have correct types - basePath() then get()', async () => {
2 unmodified lines
354 type AppType = typeof app355 const client = hc<AppType>('http://localhost')356 const res = await client.api.search.$get()357 const data = await res.json()358 type verify = Expect<Equal<true, typeof data.ok>>358 type verify = Expect<Equal<boolean, typeof data.ok>>359 expect(data.ok).toBe(true)360 })361362 it('Should have correct types - with interface', async () => {
73 unmodified lines
modified:src/validator/validator.test.ts+1 added-1 removed
519 unmodified lines
520 q: string521 }522 }523 output: {524 success: true524 success: boolean525 }526 }527 }528 }
103 unmodified lines
modified:src/context.ts-18 removed
43 unmodified lines
44}4546interface JSONTRespond {47 <T>(48 object: T extends JSONValue ? T : JSONValue,49 status?: StatusCode,50 headers?: HeaderRecord51 ): TypedResponse<52 InterfaceToType<T> extends JSONValue53 ? JSONValue extends InterfaceToType<T>54 ? never55 : T56 : never57 >58 <T>(48 object: InterfaceToType<T> extends JSONValue ? T : JSONValue,49 status?: StatusCode,50 headers?: HeaderRecord51 ): TypedResponse<
2 unmodified lines
54 ? never55 : T56 : never57 >69 <T>(object: T extends JSONValue ? T : JSONValue, init?: ResponseInit): TypedResponse<70 InterfaceToType<T> extends JSONValue71 ? JSONValue extends InterfaceToType<T>72 ? never73 : T74 : never75 >58 <T>(59 object: InterfaceToType<T> extends JSONValue ? T : JSONValue,60 init?: ResponseInit61 ): TypedResponse<
357 unmodified lines
modified:src/types.test.ts+1 added-1 removed
172 unmodified lines
173 id: string174 }175 }176 output: {177 success: true177 success: boolean178 }179 }180 }181 }
261 unmodified lines