DefinitelyTyped/types/node/querystring.d.ts
Oliver Joseph Ash d9f74cb42c Node: tighten URL query type (#33997)
* Add failing test

* Fix failing test

* Specify min version

* Name type and export

* Move type

* Use interface

* Use index signature

* Relocate test, fix 2.0 support

* Replace type alias with inline type + comments
2019-04-08 12:41:52 -07:00

25 lines
869 B
TypeScript

declare module "querystring" {
interface StringifyOptions {
encodeURIComponent?: (str: string) => string;
}
interface ParseOptions {
maxKeys?: number;
decodeURIComponent?: (str: string) => string;
}
interface ParsedUrlQuery { [key: string]: string | string[]; }
interface ParsedUrlQueryInput {
[key: string]:
// The value type here is a "poor man's `unknown`". When these types support TypeScript
// 3.0+, we can replace this with `unknown`.
{} | null | undefined;
}
function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;
function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
function escape(str: string): string;
function unescape(str: string): string;
}