Merge pull request #760 from preactjs/inline-polka-types

Fix incorrect middleware typings
This commit is contained in:
Marvin Hagemeister 2021-07-11 10:06:56 +02:00 committed by GitHub
commit d5254f10b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'wmr': patch
---
Fix incorrect middleware `request` typings

View File

@ -2,11 +2,39 @@
declare module 'wmr' {
import { Plugin as RollupPlugin, OutputOptions, RollupError, RollupWatcherEvent } from 'rollup';
import { Middleware } from 'polka';
import { ServerResponse, IncomingMessage } from 'http';
export type Mode = 'start' | 'serve' | 'build';
export { Middleware };
export interface Request extends IncomingMessage {
/**
* The originally-requested URL, including parent router segments.
*/
originalUrl: string;
/**
* The path portion of the requested URL.
*/
path: string;
/**
* The values of named parameters within your route pattern
*/
params: Record<string, string>;
/**
* The un-parsed querystring
*/
search: string | null;
/**
* The parsed querystring
*/
query: Record<string, string | string[]>;
}
export type Next = (err?: string | Error) => void;
export type Middleware = (req: Request, res: ServerResponse, next: Next) => void;
export type OutputOption = OutputOptions | ((opts: OutputOptions) => OutputOptions);