Skip to content
Myr

fix(context): default JSONRespond and TextRespond StatusCode generic arg (#2954)

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

* fix: default JSONRespond and TextRespond StatusCode generic arg * chore: format * revert

authored by Ame_x · committed by GitHub · parent e1e0e09 · Browse files · 1 file+12 added−6 removed
This commit

State

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

Diff stats

1 file+12 added−6 removed

  • other:+12 added−6 removed

1 file+12 added−6 removed

modified:src/context.ts+12 added-6 removed
108 unmodified lines
109 *110 * @returns {Response & TypedResponse<T, U, 'text'>} - The response after rendering the text content, typed with the provided text and status code types.111 */112interface TextRespond {113 <T extends string, U extends StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response &113 <T extends string, U extends StatusCode = StatusCode>(114 text: T,115 status?: U,116 headers?: HeaderRecord117 ): Response & TypedResponse<T, U, 'text'>118 <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response &119 TypedResponse<T, U, 'text'>115 <T extends string, U extends StatusCode>(text: T, init?: ResponseInit): Response &116 TypedResponse<T, U, 'text'>120}121122/**123 * Interface for responding with JSON.
8 unmodified lines
132 *133 * @returns {JSONRespondReturn<T, U>} - The response after rendering the JSON object, typed with the provided object and status code types.134 */135interface JSONRespond {133 <T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode>(136 <T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode = StatusCode>(137 object: T,138 status?: U,139 headers?: HeaderRecord140 ): JSONRespondReturn<T, U>138 <T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode>(141 <T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode = StatusCode>(142 object: T,143 init?: ResponseInit144 ): JSONRespondReturn<T, U>145}
517 unmodified lines
663 * return c.json({ message: 'Hello!' })664 * })665 * ```666 */664 json: JSONRespond = <T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode>(667 json: JSONRespond = <668 T extends JSONValue | SimplifyDeepArray<unknown>,669 U extends StatusCode = StatusCode670 >(671 object: T,672 arg?: U | ResponseInit,673 headers?: HeaderRecord674 ): JSONRespondReturn<T, U> => {
77 unmodified lines