Skip to content
Myr

feat(handler): "schema" allow normal types (#700)

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

* feat(handler): "schema" allow normal types * check types for handler+validator+handler pattern * denoify * improve type definitions

authored by Yusuke Wada · committed by GitHub · parent 3423143 · Browse files · 14 files+175 added−171 removed
This commit

State

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

Diff stats

14 files+175 added−171 removed

  • tests:+39 added−18 removed
  • other:+136 added−153 removed

14 files+175 added−171 removed

modified:deno_dist/middleware/html/index.ts+4 added-2 removed
modified:deno_dist/middleware/validator/middleware.ts+13 added-10 removed
modified:deno_dist/context.ts+2 added-1 removed
11 unmodified lines
1213export class Context<14 P extends string = string,15 E extends Partial<Environment> = Environment,16 S extends Partial<Schema> = Schema16 // eslint-disable-next-line @typescript-eslint/no-explicit-any17 S = any18> {19 req: Request<unknown, P, S extends Schema ? SchemaToProp<S> : S>20 env: E['Bindings']21 finalized: boolean
208 unmodified lines
modified:deno_dist/hono.ts+29 added-25 removed
8 unmodified lines
9import { TrieRouter } from './router/trie-router/index.ts'10import type { ExecutionContext } from './types.ts'11import type { Handler, Environment, ParamKeys, ErrorHandler, NotFoundHandler } from './types.ts'12import { getPathFromURL, mergePath } from './utils/url.ts'13import type { Schema } from './validator/schema.ts'1314interface HandlerInterface<15 P extends string,17 E extends Partial<Environment>,18 S extends Partial<Schema>,16 E extends Partial<Environment> = Environment,17 S = unknown,18 U = Hono<E, P, S>19> {20 // app.get(handler...)22 <Path extends string, Data extends Schema>(21 <Path extends string, Data = S>(22 ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, E, Data>[]24 ): U25 (...handlers: Handler<string, E, S>[]): U23 ): Hono<E, Path, Data & S>24 (...handlers: Handler<P, E, S>[]): U2526 // app.get('/', handler, handler...)28 <Path extends string, Data extends Partial<Schema> = Schema>(27 <Path extends string, Data = S>(28 path: Path,29 ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, E, Data>[]31 ): U32 <Path extends string, Data extends Schema>(path: Path, ...handlers: Handler<string, E, Data>[]): U33 (path: string, ...handlers: Handler<string, E, S>[]): U30 ): Hono<E, Path, Data & S>31 <Path extends string, Data = S>(path: Path, ...handlers: Handler<string, E, Data>[]): Hono<32 E,33 string,34 Data & S35 >36 (path: string, ...handlers: Handler<P, E, S>[]): U37}3839type Methods = typeof METHODS[number] | typeof METHOD_NAME_ALL_LOWERCASE4041function defineDynamicClass(): {42 new <43 E extends Partial<Environment> = Environment,44 P extends string = string,42 S extends Partial<Schema> = Schema,45 S = unknown,46 U = Hono<E, P, S>47 >(): {48 [K in Methods]: HandlerInterface<P, E, S, U>49 }
3 unmodified lines
5354interface Route<55 P extends string = string,56 E extends Partial<Environment> = Environment,54 S extends Partial<Schema> = Schema57 S = unknown58> {59 path: string60 method: string61 handler: Handler<P, E, S>
1 unmodified line
6364export class Hono<65 E extends Partial<Environment> = Environment,66 P extends string = '/',64 S extends Partial<Schema> = Schema67 S = unknown68> extends defineDynamicClass()<E, P, S, Hono<E, P, S>> {69 readonly router: Router<Handler<P, E, S>> = new SmartRouter({70 routers: [new StaticRouter(), new RegExpRouter(), new TrieRouter()],71 })
9 unmodified lines
81 extendRequestPrototype()8283 const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]84 allMethods.map((method) => {82 this[method] = <Env extends Environment, Data extends Schema>(85 this[method] = <Env extends Environment, Data>(86 args1: string | Handler<string, Env, Data>,87 ...args: Handler<string, Env, Data>[]88 ) => {89 if (typeof args1 === 'string') {
5 unmodified lines
95 if (typeof handler !== 'string') {96 this.addRoute(method, this.path, handler as unknown as Handler<P, E, S>)97 }98 })96 return this99 // eslint-disable-next-line @typescript-eslint/no-explicit-any100 return this as unknown as Hono<E, any, any>101 }102 })103104 Object.assign(this, init)
20 unmodified lines
125 }126 return this127 }128125 use<Path extends string = string, Data extends Partial<Schema> = Schema>(129 use<Path extends string = string, Data = unknown>(130 ...middleware: Handler<Path, E, Data>[]131 ): Hono<E, P, S>128 use<Path extends string = string, Data extends Partial<Schema> = Schema>(132 use<Path extends string = string, Data = unknown>(133 arg1: string,134 ...middleware: Handler<Path, E, Data>[]135 ): Hono<E, P, S>136 use(arg1: string | Handler<P, E, S>, ...handlers: Handler<P, E, S>[]) {
67 unmodified lines
204205 const result = this.matchRoute(method, path)206 request.paramData = result?.params207204 const c = new Context<string, E, S>(request, env, eventOrExecutionCtx, this.notFoundHandler)208 const c = new Context<string, E>(request, env, eventOrExecutionCtx, this.notFoundHandler)209210 // Do not `compose` if it has only one handler211 if (result && result.handlers.length === 1) {212 const handler = result.handlers[0]213 let res: ReturnType<Handler<P>>214215 try {212 res = handler(c, async () => {})213 if (!res) return this.notFoundHandler(c as Context)216 res = handler(c as unknown as Context<string, E, S>, async () => {})217 if (!res) return this.notFoundHandler(c)218 } catch (err) {215 return this.handleError(err, c as Context)219 return this.handleError(err, c)220 }221222 if (res instanceof Response) return res223
1 unmodified line
225 let awaited: Response | undefined | void226 try {227 awaited = await res228 if (!awaited) {225 return this.notFoundHandler(c as Context)229 return this.notFoundHandler(c)230 }231 } catch (err) {228 return this.handleError(err, c as Context)232 return this.handleError(err, c)233 }234 return awaited235 })()236 }237238 const handlers = result ? result.handlers : [this.notFoundHandler]235 const composed = compose<Context<P, E, S>, E>(handlers, this.notFoundHandler, this.errorHandler)239 const composed = compose<Context<P, E>, E>(handlers, this.notFoundHandler, this.errorHandler)240241 return (async () => {242 try {243 const tmp = composed(c)
4 unmodified lines
248 )249 }250 return context.res251 } catch (err) {248 return this.handleError(err, c as Context)252 return this.handleError(err, c)253 }254 })()255 }256
13 unmodified lines
modified:deno_dist/request.ts+6 added-14 removed
2 unmodified lines
3import type { Cookie } from './utils/cookie.ts'4import { parse } from './utils/cookie.ts'5import { getQueryStringFromURL } from './utils/url.ts'67type ValidatedData = Record<string, unknown>87declare global {8 interface Request<9 // eslint-disable-next-line @typescript-eslint/no-unused-vars10 CfHostMetadata = unknown,11 ParamKeyType extends string = string,14 Data extends ValidatedData = ValidatedData12 // eslint-disable-next-line @typescript-eslint/no-explicit-any13 Data = any14 > {15 paramData?: Record<ParamKeyType, string>16 param: {17 (key: ParamKeyType): string
23 unmodified lines
41 jsonData?: any42 json<T>(): Promise<T>43 data: Data44 valid: {46 (key: string | string[], value: unknown): Data45 (data: Data): Data46 (): Data47 }48 }49}
102 unmodified lines
152 }153 return jsonData154 } as InstanceType<typeof Request>['jsonData']155157 Request.prototype.valid = function (this: Request, keys?: string | string[], value?: unknown) {156 Request.prototype.valid = function (this: Request, data?: unknown) {157 if (!this.data) {158 this.data = {}159 }161 if (keys !== undefined) {162 if (typeof keys === 'string') {163 keys = [keys]164 }165 let data = this.data166 for (let i = 0; i < keys.length - 1; i++) {167 data = (data[keys[i]] ||= {}) as ValidatedData168 }169 data[keys[keys.length - 1]] = value160 if (data) {161 this.data = data162 }163 return this.data164 } as InstanceType<typeof Request>['valid']165}
modified:deno_dist/types.ts+14 added-24 removed
13 unmodified lines
1415export type Handler<16 P extends string = string,17 E extends Partial<Environment> = Environment,18 S extends Partial<Schema> = Schema18 S = unknown19> = (c: Context<P, E, S>, next: Next) => Response | Promise<Response | undefined | void>2021export type MiddlewareHandler<22 P extends string = string,23 E extends Partial<Environment> = Environment,24 S extends Partial<Schema> = Schema24 S = unknown25> = (c: Context<P, E, S>, next: Next) => Promise<Response | undefined | void>2627export type NotFoundHandler<E extends Partial<Environment> = Environment> = (28 c: Context<string, E>
20 unmodified lines
49 : ParamKey<Path>5051// This is not used for internally52// Will be used by users as `Handler`53export interface CustomHandler<54 P extends string | Partial<Environment> | Schema = string,55 E = Partial<Environment> | Partial<Schema>,56 S = Partial<Schema>57> {53// eslint-disable-next-line @typescript-eslint/no-explicit-any54export interface CustomHandler<P = string, E = Partial<Environment>, S = any> {55 (56 c: Context<57 P extends string ? P : string,58 P extends Partial<Environment> ? P : E extends Partial<Environment> ? E : never,59 P extends string61 ? P60 ? E extends Partial<Environment>61 ? S62 : P extends Partial<Environment>63 ? E64 : never65 : P extends Partial<Environment>63 ? string64 : P extends Partial<Schema>65 ? string66 : never,67 P extends Partial<Environment>68 ? P66 ? E extends Partial<Environment>67 ? S69 : P extends Partial<Schema>70 ? Partial<Environment>71 : E extends Partial<Environment>72 ? E extends Partial<Schema>73 ? Environment68 : E75 : E extends Partial<Schema>76 ? Partial<Environment>77 : Environment,78 // eslint-disable-next-line @typescript-eslint/no-explicit-any79 S extends Schema ? S : P extends Schema ? P : E extends Schema ? E : any69 : P70 >,71 next: Next72 ): Response | Promise<Response | undefined | void>73}
5 unmodified lines
modified:src/middleware/html/index.ts+4 added-2 removed
12 unmodified lines
1314 for (let i = 0, len = strings.length - 1; i < len; i++) {15 buffer[0] += strings[i]1617 const children =17 const children = values[i] instanceof Array ? (values[i] as Array<unknown>).flat(Infinity) : [values[i]]18 values[i] instanceof Array ? (values[i] as Array<unknown>).flat(Infinity) : [values[i]]19 for (let i = 0, len = children.length; i < len; i++) {20 // eslint-disable-next-line @typescript-eslint/no-explicit-any19 const child = children[i]21 const child = children[i] as any22 if (typeof child === 'string') {23 escapeToBuffer(child, buffer)24 } else if (typeof child === 'boolean' || child === null || child === undefined) {25 continue
14 unmodified lines
modified:src/middleware/validator/middleware.test.ts+26 added-18 removed
1/* eslint-disable @typescript-eslint/no-unused-vars */2import { Hono } from '../../hono'3import { getStatusText } from '../../utils/http-status'3import type { CustomHandler } from '../../types'4import type { Expect, Equal } from '../../utils/types'5import type { Schema } from '../../validator/schema'5import { validator } from './index'67describe('Basic - query', () => {8 const app = new Hono()
471 unmodified lines
480 })481})482483describe('Check duplicate values', () => {485 const app = new Hono()486 app.post(487 '/bar',488 async (c, next) => {489 const data = await c.req.parseBody()490 // Use `c.set`/`c.get`491 c.set('mail2', data['mail2'])492 await next()493 },494 validator((v, c) => ({495 mail: v.body('mail1').isEqual(c.get('mail2')),496 })),497 (c) => {498 return c.text('Valid')499 }500 )484 type Env = { Variables: { mail2: string } }485486 const app = new Hono<Env>()487 app488 .post(489 '/bar',490 validator((v) => ({491 mail2: v.body('mail2').isRequired(),492 })),493 async (c, next) => {494 c.set('mail2', c.req.valid()['mail2'])495 await next()496 }497 )498 .post(499 validator((v, c) => ({500 mail: v.body('mail1').isEqual(c.get('mail2')),501 })),502 (c) => {503 const { mail } = c.req.valid()504 type verifyBindings = Expect<Equal<typeof mail, string>>505 return c.text('Valid')506 }507 )508509 it('Should return 200 response - duplicate values', async () => {510 const formData = new FormData()511 formData.append('mail1', 'foo@honojs.dev')512 formData.append('mail2', 'foo@honojs.dev')
2 unmodified lines
515 body: formData,516 })517 const res = await app.request(req)518 expect(res.status).toBe(200)519 expect(await res.text()).toBe('Valid')520 })521})522523describe('Remove additional properties', () => {
364 unmodified lines
modified:src/middleware/validator/middleware.ts+13 added-10 removed
18 unmodified lines
1920type ValidationFunction<21 P extends string,22 E extends Partial<Environment> = Environment,23 S extends Schema = Schema23 S = unknown24> = (v: Validator, c: Context<P, E>) => S2526export const validatorMiddleware = <27 P extends string,28 E extends Partial<Environment> = Environment,29 S extends Schema = Schema29 S = unknown30>(31 validationFunction: ValidationFunction<P, E, S>,32 options?: { done?: Done<P, E> }33) => {
5 unmodified lines
39 results: [],40 }4142 const schema = validationFunction(v, c)43 const validatorList = getValidatorList(schema)44 let data: Record<string, unknown> = {}43 const validatorList = getValidatorList<S>(schema)44 // eslint-disable-next-line @typescript-eslint/no-explicit-any45 let data: any = {}4647 for (const [keys, validator] of validatorList) {48 let results: ValidateResult[]49 try {
42 unmodified lines
92 if (jsonData) {93 const dst = data94 data = mergeObjects(dst, jsonData)95 } else {95 c.req.valid(keys, value)96 let tmp = data97 for (let i = 0; i < keys.length - 1; i++) {98 tmp = tmp[keys[i]] ||= {}99 }100 tmp[keys[keys.length - 1]] = value101 }102 }103 }104105 if (!resultSet.hasError) {101 Object.keys(data).map((key) => {102 c.req.valid(key, data[key])103 })106 c.req.valid(data)107 }108109 if (options && options.done) {110 const res = options.done(resultSet, c)
9 unmodified lines
120 }121 return handler122}123121function getValidatorList<T extends Schema>(schema: T) {124function getValidatorList<T>(schema: T) {125 const map: [string[], VBase][] = []123 for (const [key, value] of Object.entries(schema)) {126 for (const [key, value] of Object.entries(schema as unknown as Schema)) {127 if (value instanceof VObjectBase) {128 const validators = value.getValidators()129 for (const validator of validators) {130 map.push([value.keys, validator])
25 unmodified lines
modified:src/context.ts+2 added-1 removed
11 unmodified lines
1213export class Context<14 P extends string = string,15 E extends Partial<Environment> = Environment,16 S extends Partial<Schema> = Schema16 // eslint-disable-next-line @typescript-eslint/no-explicit-any17 S = any18> {19 req: Request<unknown, P, S extends Schema ? SchemaToProp<S> : S>20 env: E['Bindings']21 finalized: boolean
208 unmodified lines
modified:src/hono.ts+29 added-25 removed
8 unmodified lines
9import { TrieRouter } from './router/trie-router'10import type { ExecutionContext } from './types'11import type { Handler, Environment, ParamKeys, ErrorHandler, NotFoundHandler } from './types'12import { getPathFromURL, mergePath } from './utils/url'13import type { Schema } from './validator/schema'1314interface HandlerInterface<15 P extends string,17 E extends Partial<Environment>,18 S extends Partial<Schema>,16 E extends Partial<Environment> = Environment,17 S = unknown,18 U = Hono<E, P, S>19> {20 // app.get(handler...)22 <Path extends string, Data extends Schema>(21 <Path extends string, Data = S>(22 ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, E, Data>[]24 ): U25 (...handlers: Handler<string, E, S>[]): U23 ): Hono<E, Path, Data & S>24 (...handlers: Handler<P, E, S>[]): U2526 // app.get('/', handler, handler...)28 <Path extends string, Data extends Partial<Schema> = Schema>(27 <Path extends string, Data = S>(28 path: Path,29 ...handlers: Handler<ParamKeys<Path> extends never ? string : ParamKeys<Path>, E, Data>[]31 ): U32 <Path extends string, Data extends Schema>(path: Path, ...handlers: Handler<string, E, Data>[]): U33 (path: string, ...handlers: Handler<string, E, S>[]): U30 ): Hono<E, Path, Data & S>31 <Path extends string, Data = S>(path: Path, ...handlers: Handler<string, E, Data>[]): Hono<32 E,33 string,34 Data & S35 >36 (path: string, ...handlers: Handler<P, E, S>[]): U37}3839type Methods = typeof METHODS[number] | typeof METHOD_NAME_ALL_LOWERCASE4041function defineDynamicClass(): {42 new <43 E extends Partial<Environment> = Environment,44 P extends string = string,42 S extends Partial<Schema> = Schema,45 S = unknown,46 U = Hono<E, P, S>47 >(): {48 [K in Methods]: HandlerInterface<P, E, S, U>49 }
3 unmodified lines
5354interface Route<55 P extends string = string,56 E extends Partial<Environment> = Environment,54 S extends Partial<Schema> = Schema57 S = unknown58> {59 path: string60 method: string61 handler: Handler<P, E, S>
1 unmodified line
6364export class Hono<65 E extends Partial<Environment> = Environment,66 P extends string = '/',64 S extends Partial<Schema> = Schema67 S = unknown68> extends defineDynamicClass()<E, P, S, Hono<E, P, S>> {69 readonly router: Router<Handler<P, E, S>> = new SmartRouter({70 routers: [new StaticRouter(), new RegExpRouter(), new TrieRouter()],71 })
9 unmodified lines
81 extendRequestPrototype()8283 const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE]84 allMethods.map((method) => {82 this[method] = <Env extends Environment, Data extends Schema>(85 this[method] = <Env extends Environment, Data>(86 args1: string | Handler<string, Env, Data>,87 ...args: Handler<string, Env, Data>[]88 ) => {89 if (typeof args1 === 'string') {
5 unmodified lines
95 if (typeof handler !== 'string') {96 this.addRoute(method, this.path, handler as unknown as Handler<P, E, S>)97 }98 })96 return this99 // eslint-disable-next-line @typescript-eslint/no-explicit-any100 return this as unknown as Hono<E, any, any>101 }102 })103104 Object.assign(this, init)
20 unmodified lines
125 }126 return this127 }128125 use<Path extends string = string, Data extends Partial<Schema> = Schema>(129 use<Path extends string = string, Data = unknown>(130 ...middleware: Handler<Path, E, Data>[]131 ): Hono<E, P, S>128 use<Path extends string = string, Data extends Partial<Schema> = Schema>(132 use<Path extends string = string, Data = unknown>(133 arg1: string,134 ...middleware: Handler<Path, E, Data>[]135 ): Hono<E, P, S>136 use(arg1: string | Handler<P, E, S>, ...handlers: Handler<P, E, S>[]) {
67 unmodified lines
204205 const result = this.matchRoute(method, path)206 request.paramData = result?.params207204 const c = new Context<string, E, S>(request, env, eventOrExecutionCtx, this.notFoundHandler)208 const c = new Context<string, E>(request, env, eventOrExecutionCtx, this.notFoundHandler)209210 // Do not `compose` if it has only one handler211 if (result && result.handlers.length === 1) {212 const handler = result.handlers[0]213 let res: ReturnType<Handler<P>>214215 try {212 res = handler(c, async () => {})213 if (!res) return this.notFoundHandler(c as Context)216 res = handler(c as unknown as Context<string, E, S>, async () => {})217 if (!res) return this.notFoundHandler(c)218 } catch (err) {215 return this.handleError(err, c as Context)219 return this.handleError(err, c)220 }221222 if (res instanceof Response) return res223
1 unmodified line
225 let awaited: Response | undefined | void226 try {227 awaited = await res228 if (!awaited) {225 return this.notFoundHandler(c as Context)229 return this.notFoundHandler(c)230 }231 } catch (err) {228 return this.handleError(err, c as Context)232 return this.handleError(err, c)233 }234 return awaited235 })()236 }237238 const handlers = result ? result.handlers : [this.notFoundHandler]235 const composed = compose<Context<P, E, S>, E>(handlers, this.notFoundHandler, this.errorHandler)239 const composed = compose<Context<P, E>, E>(handlers, this.notFoundHandler, this.errorHandler)240241 return (async () => {242 try {243 const tmp = composed(c)
4 unmodified lines
248 )249 }250 return context.res251 } catch (err) {248 return this.handleError(err, c as Context)252 return this.handleError(err, c)253 }254 })()255 }256
13 unmodified lines
modified:src/request.ts+6 added-14 removed
2 unmodified lines
3import type { Cookie } from './utils/cookie'4import { parse } from './utils/cookie'5import { getQueryStringFromURL } from './utils/url'67type ValidatedData = Record<string, unknown>87declare global {8 interface Request<9 // eslint-disable-next-line @typescript-eslint/no-unused-vars10 CfHostMetadata = unknown,11 ParamKeyType extends string = string,14 Data extends ValidatedData = ValidatedData12 // eslint-disable-next-line @typescript-eslint/no-explicit-any13 Data = any14 > {15 paramData?: Record<ParamKeyType, string>16 param: {17 (key: ParamKeyType): string
23 unmodified lines
41 jsonData?: any42 json<T>(): Promise<T>43 data: Data44 valid: {46 (key: string | string[], value: unknown): Data45 (data: Data): Data46 (): Data47 }48 }49}
102 unmodified lines
152 }153 return jsonData154 } as InstanceType<typeof Request>['jsonData']155157 Request.prototype.valid = function (this: Request, keys?: string | string[], value?: unknown) {156 Request.prototype.valid = function (this: Request, data?: unknown) {157 if (!this.data) {158 this.data = {}159 }161 if (keys !== undefined) {162 if (typeof keys === 'string') {163 keys = [keys]164 }165 let data = this.data166 for (let i = 0; i < keys.length - 1; i++) {167 data = (data[keys[i]] ||= {}) as ValidatedData168 }169 data[keys[keys.length - 1]] = value160 if (data) {161 this.data = data162 }163 return this.data164 } as InstanceType<typeof Request>['valid']165}
modified:src/types.test.ts+13 added
147 unmodified lines
148 res = await app.request('http://localhost/?q=bar')149 expect(res.status).toBe(200)150 expect(await res.text()).toBe('bar')151 })152153 test('Normal types', () => {154 type User = {155 name: string156 age: number157 }158159 const handler: Handler<User> = (c) => {160 const user = c.req.valid()161 type verifySchema = Expect<Equal<typeof user, User>>162 return c.text('Hi')163 }164 })165})
modified:src/types.ts+14 added-25 removed
1import type { Context } from './context'2import type { Schema } from './validator/schema'23export interface ContextVariableMap {}45// eslint-disable-next-line @typescript-eslint/no-explicit-any
7 unmodified lines
1314export type Handler<15 P extends string = string,16 E extends Partial<Environment> = Environment,18 S extends Partial<Schema> = Schema17 S = unknown18> = (c: Context<P, E, S>, next: Next) => Response | Promise<Response | undefined | void>1920export type MiddlewareHandler<21 P extends string = string,22 E extends Partial<Environment> = Environment,24 S extends Partial<Schema> = Schema23 S = unknown24> = (c: Context<P, E, S>, next: Next) => Promise<Response | undefined | void>2526export type NotFoundHandler<E extends Partial<Environment> = Environment> = (27 c: Context<string, E>
20 unmodified lines
48 : ParamKey<Path>4950// This is not used for internally51// Will be used by users as `Handler`53export interface CustomHandler<54 P extends string | Partial<Environment> | Schema = string,55 E = Partial<Environment> | Partial<Schema>,56 S = Partial<Schema>57> {52// eslint-disable-next-line @typescript-eslint/no-explicit-any53export interface CustomHandler<P = string, E = Partial<Environment>, S = any> {54 (55 c: Context<56 P extends string ? P : string,57 P extends Partial<Environment> ? P : E extends Partial<Environment> ? E : never,58 P extends string61 ? P59 ? E extends Partial<Environment>60 ? S61 : P extends Partial<Environment>62 ? E63 : never64 : P extends Partial<Environment>63 ? string64 : P extends Partial<Schema>65 ? string66 : never,67 P extends Partial<Environment>68 ? P65 ? E extends Partial<Environment>66 ? S69 : P extends Partial<Schema>70 ? Partial<Environment>71 : E extends Partial<Environment>72 ? E extends Partial<Schema>73 ? Environment67 : E75 : E extends Partial<Schema>76 ? Partial<Environment>77 : Environment,78 // eslint-disable-next-line @typescript-eslint/no-explicit-any79 S extends Schema ? S : P extends Schema ? P : E extends Schema ? E : any68 : P69 >,70 next: Next71 ): Response | Promise<Response | undefined | void>72}
5 unmodified lines