refactor(hono-base): remove `any` casting (#1535)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* refactor(hono-base): remove `any` casting * denoify
authored by Yusuke Wada · committed by GitHub · parent e326208 · Browse files · 2 files·+12 added−24 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+12 added−24 removed
- other:+12 added−24 removed
Provenance
- Commit
93fec33- Tree
18bc1d6- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
e326208
2 files changed+12 added−24 removed
modified:deno_dist/hono-base.ts+6 added-12 removed
88 unmodified lines89 if (typeof handler !== 'string') {90 this.addRoute(method, this.path, handler)91 }92 })93- // eslint-disable-next-line @typescript-eslint/no-explicit-any94- return this as any93+ return this94 }95 })96 97 // Implementation of app.on(method, path, ...handlers[])4 unmodified lines102 handlers.map((handler) => {103 this.addRoute(m.toUpperCase(), this.path, handler)104 })105 }107- // eslint-disable-next-line @typescript-eslint/no-explicit-any108- return this as any106+ return this107 }108 109 // Implementation of app.use(...handlers[]) or app.get(path, ...handlers[])110 // eslint-disable-next-line @typescript-eslint/no-explicit-any53 unmodified lines164 ): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath> {165 const subApp = this.basePath(path)166 167 if (!app) {170- // eslint-disable-next-line @typescript-eslint/no-explicit-any171- return subApp as any168+ return subApp169 }170 171 app.routes.map((r) => {172 const handler =2 unmodified lines175 : async (c: Context, next: Next) =>176 (await compose<Context>([r.handler], app.errorHandler)(c, next)).res177 subApp.addRoute(r.method, r.path, handler)178 })182- // eslint-disable-next-line @typescript-eslint/no-explicit-any183- return this as any179+ return this180 }181 182 basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>> {183 const subApp = this.clone()184 subApp._basePath = mergePath(this._basePath, path)189- // eslint-disable-next-line @typescript-eslint/no-explicit-any190- return subApp as any185+ return subApp186 }187 188 onError(handler: ErrorHandler<E>) {189 this.errorHandler = handler94 unmodified lines284 executionCtx: ExecutionContext | FetchEventLike | undefined,285 env: E['Bindings'],286 method: string287 ): Response | Promise<Response> {293- const path = this.getPath(request, { env })294-288 // Handle HEAD method289 if (method === 'HEAD') {290 return (async () =>291 new Response(null, await this.dispatch(request, executionCtx, env, 'GET')))()292 }293 294+ const path = this.getPath(request, { env })295 const { handlers, params } = this.matchRoute(method, path)296 297 const c = new Context(new HonoRequest(request, path, params), {298 env,101 unmodified linesmodified:src/hono-base.ts+6 added-12 removed
88 unmodified lines89 if (typeof handler !== 'string') {90 this.addRoute(method, this.path, handler)91 }92 })93- // eslint-disable-next-line @typescript-eslint/no-explicit-any94- return this as any93+ return this94 }95 })96 97 // Implementation of app.on(method, path, ...handlers[])4 unmodified lines102 handlers.map((handler) => {103 this.addRoute(m.toUpperCase(), this.path, handler)104 })105 }107- // eslint-disable-next-line @typescript-eslint/no-explicit-any108- return this as any106+ return this107 }108 109 // Implementation of app.use(...handlers[]) or app.get(path, ...handlers[])110 // eslint-disable-next-line @typescript-eslint/no-explicit-any53 unmodified lines164 ): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath> {165 const subApp = this.basePath(path)166 167 if (!app) {170- // eslint-disable-next-line @typescript-eslint/no-explicit-any171- return subApp as any168+ return subApp169 }170 171 app.routes.map((r) => {172 const handler =2 unmodified lines175 : async (c: Context, next: Next) =>176 (await compose<Context>([r.handler], app.errorHandler)(c, next)).res177 subApp.addRoute(r.method, r.path, handler)178 })182- // eslint-disable-next-line @typescript-eslint/no-explicit-any183- return this as any179+ return this180 }181 182 basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>> {183 const subApp = this.clone()184 subApp._basePath = mergePath(this._basePath, path)189- // eslint-disable-next-line @typescript-eslint/no-explicit-any190- return subApp as any185+ return subApp186 }187 188 onError(handler: ErrorHandler<E>) {189 this.errorHandler = handler94 unmodified lines284 executionCtx: ExecutionContext | FetchEventLike | undefined,285 env: E['Bindings'],286 method: string287 ): Response | Promise<Response> {293- const path = this.getPath(request, { env })294-288 // Handle HEAD method289 if (method === 'HEAD') {290 return (async () =>291 new Response(null, await this.dispatch(request, executionCtx, env, 'GET')))()292 }293 294+ const path = this.getPath(request, { env })295 const { handlers, params } = this.matchRoute(method, path)296 297 const c = new Context(new HonoRequest(request, path, params), {298 env,101 unmodified lines