0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00

fix(types): corrected argument types for Context methods (#1357)

This commit is contained in:
asaxeye 2023-08-21 00:23:05 +09:00 committed by GitHub
parent 2b274662e9
commit 88e7650ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -207,7 +207,7 @@ export class Context<
})
}
// Return Response immediately if arg is RequestInit.
// Return Response immediately if arg is ResponseInit.
if (arg && typeof arg !== 'number') {
const res = new Response(data, arg)
const contentType = this._pH?.['content-type']
@ -254,7 +254,7 @@ export class Context<
body: BodyRespond = (
data: Data | null,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): Response => {
return typeof arg === 'number'
@ -264,7 +264,7 @@ export class Context<
text: TextRespond = (
text: string,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): Response => {
// If the header is empty, return Response immediately.
@ -287,7 +287,7 @@ export class Context<
json: JSONRespond = <T = {}>(
object: T,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
) => {
const body = JSON.stringify(object)
@ -300,7 +300,7 @@ export class Context<
jsonT: JSONTRespond = <T>(
object: InterfaceToType<T> extends JSONValue ? T : JSONValue,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): TypedResponse<
InterfaceToType<T> extends JSONValue
@ -319,7 +319,7 @@ export class Context<
html: HTMLRespond = (
html: string,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): Response => {
this._pH ??= {}

View File

@ -207,7 +207,7 @@ export class Context<
})
}
// Return Response immediately if arg is RequestInit.
// Return Response immediately if arg is ResponseInit.
if (arg && typeof arg !== 'number') {
const res = new Response(data, arg)
const contentType = this._pH?.['content-type']
@ -254,7 +254,7 @@ export class Context<
body: BodyRespond = (
data: Data | null,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): Response => {
return typeof arg === 'number'
@ -264,7 +264,7 @@ export class Context<
text: TextRespond = (
text: string,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): Response => {
// If the header is empty, return Response immediately.
@ -287,7 +287,7 @@ export class Context<
json: JSONRespond = <T = {}>(
object: T,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
) => {
const body = JSON.stringify(object)
@ -300,7 +300,7 @@ export class Context<
jsonT: JSONTRespond = <T>(
object: InterfaceToType<T> extends JSONValue ? T : JSONValue,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): TypedResponse<
InterfaceToType<T> extends JSONValue
@ -319,7 +319,7 @@ export class Context<
html: HTMLRespond = (
html: string,
arg?: StatusCode | RequestInit,
arg?: StatusCode | ResponseInit,
headers?: HeaderRecord
): Response => {
this._pH ??= {}