From eeb8aa8b116038671b7436173fab1994d4645767 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 18 May 2022 17:38:12 +0300 Subject: [PATCH] fix: types for `Request` and `Response` (#1271) --- package-lock.json | 32 ++++++++++++++++++++++++++------ package.json | 1 + types/index.d.ts | 17 +++++++++-------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4893e357..d393a6545 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,7 @@ "standard-version": "^9.3.0", "strip-ansi": "^6.0.0", "supertest": "^6.1.3", + "typescript": "4.5.5", "webpack": "^5.68.0" }, "engines": { @@ -1993,6 +1994,19 @@ "node": ">=8" } }, + "node_modules/@commitlint/load/node_modules/typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@commitlint/message": { "version": "17.0.0", "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-17.0.0.tgz", @@ -12602,9 +12616,9 @@ "dev": true }, "node_modules/typescript": { - "version": "4.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", - "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -14526,6 +14540,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true } } }, @@ -22530,9 +22550,9 @@ "dev": true }, "typescript": { - "version": "4.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", - "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index b773b7805..804e15bbe 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "standard-version": "^9.3.0", "strip-ansi": "^6.0.0", "supertest": "^6.1.3", + "typescript": "4.5.5", "webpack": "^5.68.0" }, "keywords": [ diff --git a/types/index.d.ts b/types/index.d.ts index a3639c5a9..a9143462b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -165,7 +165,7 @@ type Options< | undefined; writeToDisk?: boolean | ((targetPath: string) => boolean) | undefined; methods?: string | undefined; - headers?: Headers; + headers?: Headers; publicPath?: NonNullable["publicPath"]; stats?: Configuration["stats"]; serverSideRender?: boolean | undefined; @@ -175,7 +175,8 @@ type Options< type API< Request_1 extends import("http").IncomingMessage, Response_1 extends ServerResponse -> = Middleware & AdditionalMethods; +> = Middleware & + AdditionalMethods; type Schema = import("schema-utils/declarations/validate").Schema; type Configuration = import("webpack").Configuration; type Stats = import("webpack").Stats; @@ -215,7 +216,7 @@ type Context< state: boolean; stats: Stats | MultiStats | undefined; callbacks: Callback[]; - options: Options; + options: Options; compiler: Compiler | MultiCompiler; watching: Watching | MultiWatching; logger: Logger; @@ -231,15 +232,15 @@ type Headers< value: number | string; }[] | (( - req: Request, - res: Response, - context: Context + req: Request_1, + res: Response_1, + context: Context ) => void | undefined | Record) | undefined; type Middleware< Request_1 extends import("http").IncomingMessage, Response_1 extends ServerResponse -> = (req: Request, res: Response, next: NextFunction) => Promise; +> = (req: Request_1, res: Response_1, next: NextFunction) => Promise; type GetFilenameFromUrl = (url: string) => string | undefined; type WaitUntilValid = (callback: Callback) => any; type Invalidate = (callback: Callback) => any; @@ -252,5 +253,5 @@ type AdditionalMethods< waitUntilValid: WaitUntilValid; invalidate: Invalidate; close: Close; - context: Context; + context: Context; };