Skip to content

Commit f33256f

Browse files
chore: types update
1 parent 8d98d11 commit f33256f

3 files changed

Lines changed: 30 additions & 21 deletions

File tree

types/index.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ export = wdm;
1212
*/
1313
/** @typedef {import("http").IncomingMessage} IncomingMessage */
1414
/** @typedef {import("http").ServerResponse & ExtendedServerResponse} ServerResponse */
15+
/** @typedef {any} EXPECTED_ANY */
16+
/** @typedef {Function} EXPECTED_FUNCTION */
1517
/**
1618
* @callback NextFunction
17-
* @param {any=} err error
19+
* @param {EXPECTED_ANY=} err error
1820
* @returns {void}
1921
*/
2022
/**
@@ -175,6 +177,8 @@ declare namespace wdm {
175177
ExtendedServerResponse,
176178
IncomingMessage,
177179
ServerResponse,
180+
EXPECTED_ANY,
181+
EXPECTED_FUNCTION,
178182
NextFunction,
179183
WatchOptions,
180184
Watching,
@@ -232,29 +236,29 @@ declare function hapiWrapper<
232236
* @template {ServerResponse} [ResponseInternal=ServerResponse]
233237
* @param {Compiler | MultiCompiler} compiler compiler
234238
* @param {Options<RequestInternal, ResponseInternal>=} options options
235-
* @returns {(ctx: any, next: Function) => Promise<void> | void} kow wrapper
239+
* @returns {(ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void} kow wrapper
236240
*/
237241
declare function koaWrapper<
238242
RequestInternal extends IncomingMessage = import("http").IncomingMessage,
239243
ResponseInternal extends ServerResponse = ServerResponse,
240244
>(
241245
compiler: Compiler | MultiCompiler,
242246
options?: Options<RequestInternal, ResponseInternal> | undefined,
243-
): (ctx: any, next: Function) => Promise<void> | void;
247+
): (ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void;
244248
/**
245249
* @template {IncomingMessage} [RequestInternal=IncomingMessage]
246250
* @template {ServerResponse} [ResponseInternal=ServerResponse]
247251
* @param {Compiler | MultiCompiler} compiler compiler
248252
* @param {Options<RequestInternal, ResponseInternal>=} options options
249-
* @returns {(ctx: any, next: Function) => Promise<void> | void} hono wrapper
253+
* @returns {(ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void} hono wrapper
250254
*/
251255
declare function honoWrapper<
252256
RequestInternal extends IncomingMessage = import("http").IncomingMessage,
253257
ResponseInternal extends ServerResponse = ServerResponse,
254258
>(
255259
compiler: Compiler | MultiCompiler,
256260
options?: Options<RequestInternal, ResponseInternal> | undefined,
257-
): (ctx: any, next: Function) => Promise<void> | void;
261+
): (ctx: EXPECTED_ANY, next: EXPECTED_FUNCTION) => Promise<void> | void;
258262
type Schema = import("schema-utils/declarations/validate").Schema;
259263
type Compiler = import("webpack").Compiler;
260264
type MultiCompiler = import("webpack").MultiCompiler;
@@ -276,7 +280,9 @@ type ExtendedServerResponse = {
276280
};
277281
type IncomingMessage = import("http").IncomingMessage;
278282
type ServerResponse = import("http").ServerResponse & ExtendedServerResponse;
279-
type NextFunction = (err?: any | undefined) => void;
283+
type EXPECTED_ANY = any;
284+
type EXPECTED_FUNCTION = Function;
285+
type NextFunction = (err?: EXPECTED_ANY | undefined) => void;
280286
type WatchOptions = NonNullable<Configuration["watchOptions"]>;
281287
type Watching = Compiler["watching"];
282288
type MultiWatching = ReturnType<MultiCompiler["watch"]>;

types/utils/compatibleAPI.d.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
export type IncomingMessage = import("../index.js").IncomingMessage;
2-
export type ServerResponse = import("../index.js").ServerResponse;
1+
export type IncomingMessage = import("../index").IncomingMessage;
2+
export type ServerResponse = import("../index").ServerResponse;
33
export type OutputFileSystem = import("../index").OutputFileSystem;
4+
export type EXPECTED_ANY = import("../index").EXPECTED_ANY;
45
export type ExpectedIncomingMessage = {
56
/**
67
* get header extra method
@@ -60,15 +61,15 @@ export type ExpectedServerResponse = {
6061
/**
6162
* stream
6263
*/
63-
stream?: ((data: any) => void) | undefined;
64+
stream?: ((data: EXPECTED_ANY) => void) | undefined;
6465
/**
6566
* get outgoing
6667
*/
67-
getOutgoing?: (() => any) | undefined;
68+
getOutgoing?: (() => EXPECTED_ANY) | undefined;
6869
/**
6970
* set state
7071
*/
71-
setState?: ((name: string, value: any) => void) | undefined;
72+
setState?: ((name: string, value: EXPECTED_ANY) => void) | undefined;
7273
};
7374
/**
7475
* @param {string} filename filename
@@ -110,9 +111,10 @@ export function getHeadersSent<
110111
export function getOutgoing<
111112
Response extends ServerResponse & ExpectedServerResponse,
112113
>(res: Response): Response;
113-
/** @typedef {import("../index.js").IncomingMessage} IncomingMessage */
114-
/** @typedef {import("../index.js").ServerResponse} ServerResponse */
114+
/** @typedef {import("../index").IncomingMessage} IncomingMessage */
115+
/** @typedef {import("../index").ServerResponse} ServerResponse */
115116
/** @typedef {import("../index").OutputFileSystem} OutputFileSystem */
117+
/** @typedef {import("../index").EXPECTED_ANY} EXPECTED_ANY */
116118
/**
117119
* @typedef {object} ExpectedIncomingMessage
118120
* @property {((name: string) => string | string[] | undefined)=} getHeader get header extra method
@@ -130,9 +132,9 @@ export function getOutgoing<
130132
* @property {((data?: string | Buffer) => void)=} finish finish
131133
* @property {(() => string[])=} getResponseHeaders get response header
132134
* @property {(() => boolean)=} getHeadersSent get headers sent
133-
* @property {((data: any) => void)=} stream stream
134-
* @property {(() => any)=} getOutgoing get outgoing
135-
* @property {((name: string, value: any) => void)=} setState set state
135+
* @property {((data: EXPECTED_ANY) => void)=} stream stream
136+
* @property {(() => EXPECTED_ANY)=} getOutgoing get outgoing
137+
* @property {((name: string, value: EXPECTED_ANY) => void)=} setState set state
136138
*/
137139
/**
138140
* @template {IncomingMessage & ExpectedIncomingMessage} Request
@@ -237,12 +239,12 @@ export function setResponseHeader<
237239
* @template {ServerResponse & ExpectedServerResponse} Response
238240
* @param {Response} res res
239241
* @param {string} name name
240-
* @param {any} value state
242+
* @param {EXPECTED_ANY} value state
241243
* @returns {void}
242244
*/
243245
export function setState<
244246
Response extends ServerResponse & ExpectedServerResponse,
245-
>(res: Response, name: string, value: any): void;
247+
>(res: Response, name: string, value: EXPECTED_ANY): void;
246248
/**
247249
* @template {ServerResponse & ExpectedServerResponse} Response
248250
* @param {Response} res res

types/utils/memorize.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export = memorize;
22
/**
33
* @template T
4-
* @typedef {(...args: any) => T} FunctionReturning
4+
* @typedef {(...args: EXPECTED_ANY) => T} FunctionReturning
55
*/
66
/**
77
* @template T
@@ -30,6 +30,7 @@ declare function memorize<T>(
3030
callback?: ((value: T) => T) | undefined,
3131
): FunctionReturning<T>;
3232
declare namespace memorize {
33-
export { FunctionReturning };
33+
export { FunctionReturning, EXPECTED_ANY };
3434
}
35-
type FunctionReturning<T> = (...args: any) => T;
35+
type FunctionReturning<T> = (...args: EXPECTED_ANY) => T;
36+
type EXPECTED_ANY = import("../index").EXPECTED_ANY;

0 commit comments

Comments
 (0)