diff --git a/application.ts b/application.ts index e4ff02de..fed8ece7 100644 --- a/application.ts +++ b/application.ts @@ -547,7 +547,7 @@ export class Application> * context gets set to not to respond, then the method resolves with * `undefined`, otherwise it resolves with a request that is compatible with * `std/http/server`. */ - handle = (async ( + handle: HandleMethod = (async ( request: Request, secureOrAddr: NetAddr | boolean | undefined, secure: boolean | undefined = false, @@ -582,7 +582,7 @@ export class Application> this.#handleError(context, err); throw err; } - }) as HandleMethod; + }); /** Start listening for requests, processing registered middleware on each * request. If the options `.secure` is undefined or `false`, the listening @@ -697,7 +697,9 @@ export class Application> return this as Application; } - [Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string) { + [Symbol.for("Deno.customInspect")]( + inspect: (value: unknown) => string, + ): string { const { keys, proxy, state } = this; return `${this.constructor.name} ${ inspect({ "#middleware": this.#middleware, keys, proxy, state }) @@ -709,7 +711,8 @@ export class Application> // deno-lint-ignore no-explicit-any options: any, inspect: (value: unknown, options?: unknown) => string, - ) { + // deno-lint-ignore no-explicit-any + ): any { if (depth < 0) { return options.stylize(`[${this.constructor.name}]`, "special"); } diff --git a/context.ts b/context.ts index c5dfab50..cd36d5bc 100644 --- a/context.ts +++ b/context.ts @@ -305,7 +305,9 @@ export class Context< return this.#socket; } - [Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string) { + [Symbol.for("Deno.customInspect")]( + inspect: (value: unknown) => string, + ): string { const { app, cookies, @@ -335,7 +337,8 @@ export class Context< // deno-lint-ignore no-explicit-any options: any, inspect: (value: unknown, options?: unknown) => string, - ) { + // deno-lint-ignore no-explicit-any + ): any { if (depth < 0) { return options.stylize(`[${this.constructor.name}]`, "special"); } diff --git a/http_server_native.ts b/http_server_native.ts index e1c2af11..2e806a62 100644 --- a/http_server_native.ts +++ b/http_server_native.ts @@ -12,17 +12,6 @@ import type { } from "./types.ts"; import { createPromiseWithResolvers } from "./util.ts"; -// this is included so when down-emitting to npm/Node.js, ReadableStream has -// async iterators -declare global { - // deno-lint-ignore no-explicit-any - interface ReadableStream { - [Symbol.asyncIterator](options?: { - preventCancel?: boolean; - }): AsyncIterableIterator; - } -} - const serve: ( options: ServeInit & (ServeOptions | ServeTlsOptions), ) => HttpServer = "serve" in Deno diff --git a/range.ts b/range.ts index 71625818..310283a2 100644 --- a/range.ts +++ b/range.ts @@ -163,7 +163,7 @@ export class MultiPartStream extends ReadableStream { } /** The content length of the entire streamed body. */ - contentLength() { + contentLength(): number { return this.#contentLength; } } diff --git a/request.ts b/request.ts index 567e928c..e85756c4 100644 --- a/request.ts +++ b/request.ts @@ -251,7 +251,9 @@ export class Request { return this.#serverRequest.upgrade(options); } - [Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string) { + [Symbol.for("Deno.customInspect")]( + inspect: (value: unknown) => string, + ): string { const { body, hasBody, headers, ip, ips, method, secure, url, userAgent } = this; return `${this.constructor.name} ${ @@ -274,7 +276,8 @@ export class Request { // deno-lint-ignore no-explicit-any options: any, inspect: (value: unknown, options?: unknown) => string, - ) { + // deno-lint-ignore no-explicit-any + ): any { if (depth < 0) { return options.stylize(`[${this.constructor.name}]`, "special"); } diff --git a/response.ts b/response.ts index 60af5ddc..59c30a63 100644 --- a/response.ts +++ b/response.ts @@ -361,7 +361,9 @@ export class Response { : new DomResponse(responseOrBody, init); } - [Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string) { + [Symbol.for("Deno.customInspect")]( + inspect: (value: unknown) => string, + ): string { const { body, headers, status, type, writable } = this; return `${this.constructor.name} ${ inspect({ body, headers, status, type, writable }) @@ -373,7 +375,8 @@ export class Response { // deno-lint-ignore no-explicit-any options: any, inspect: (value: unknown, options?: unknown) => string, - ) { + // deno-lint-ignore no-explicit-any + ): any { if (depth < 0) { return options.stylize(`[${this.constructor.name}]`, "special"); } diff --git a/router.ts b/router.ts index 56c13332..fa1cb012 100644 --- a/router.ts +++ b/router.ts @@ -300,7 +300,7 @@ export class Layer< params( captures: string[], - existingParams = {} as RouteParams, + existingParams: RouteParams = {} as RouteParams, ): RouteParams { const params = existingParams; for (let i = 0; i < captures.length; i++) { @@ -320,7 +320,7 @@ export class Layer< } url( - params = {} as RouteParams, + params: RouteParams = {} as RouteParams, options?: UrlOptions, ): string { const url = this.path.replace(/\(\.\*\)/g, ""); @@ -331,7 +331,7 @@ export class Layer< param: string, // deno-lint-ignore no-explicit-any fn: RouterParamMiddleware, - ) { + ): this { const stack = this.stack; const params = this.#paramNames; const middleware: RouterMiddleware = function ( @@ -383,7 +383,9 @@ export class Layer< }; } - [Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string) { + [Symbol.for("Deno.customInspect")]( + inspect: (value: unknown) => string, + ): string { return `${this.constructor.name} ${ inspect({ methods: this.methods, @@ -401,7 +403,8 @@ export class Layer< // deno-lint-ignore no-explicit-any options: any, inspect: (value: unknown, options?: unknown) => string, - ) { + // deno-lint-ignore no-explicit-any + ): any { if (depth < 0) { return options.stylize(`[${this.constructor.name}]`, "special"); } @@ -1400,7 +1403,9 @@ export class Router< return toUrl(path, params, options); } - [Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string) { + [Symbol.for("Deno.customInspect")]( + inspect: (value: unknown) => string, + ): string { return `${this.constructor.name} ${ inspect({ "#params": this.#params, "#stack": this.#stack }) }`; @@ -1411,7 +1416,8 @@ export class Router< // deno-lint-ignore no-explicit-any options: any, inspect: (value: unknown, options?: unknown) => string, - ) { + // deno-lint-ignore no-explicit-any + ): any { if (depth < 0) { return options.stylize(`[${this.constructor.name}]`, "special"); } diff --git a/testing.ts b/testing.ts index 42099c4f..9d225a51 100644 --- a/testing.ts +++ b/testing.ts @@ -24,7 +24,7 @@ import { Response } from "./response.ts"; export function createMockApp< S extends Record = Record, >( - state = {} as S, + state: S = {} as S, ): Application { const app = { state, @@ -91,7 +91,7 @@ export function createMockContext< app = createMockApp(state), headers: requestHeaders, }: MockContextOptions = {}, -) { +): RouterContext { function createMockRequest(): Request { const headers = new Headers(requestHeaders); return { @@ -178,6 +178,6 @@ export function createMockContext< /** Creates a mock `next()` function which can be used when calling * middleware. */ -export function createMockNext() { +export function createMockNext(): () => Promise { return async function next() {}; }