UNPKG

1.12 kBTypeScriptView Raw
1declare module "querystring" {
2 interface StringifyOptions {
3 encodeURIComponent?: (str: string) => string;
4 }
5
6 interface ParseOptions {
7 maxKeys?: number;
8 decodeURIComponent?: (str: string) => string;
9 }
10
11 interface ParsedUrlQuery { [key: string]: string | string[]; }
12
13 interface ParsedUrlQueryInput {
14 [key: string]:
15 // The value type here is a "poor man's `unknown`". When these types support TypeScript
16 // 3.0+, we can replace this with `unknown`.
17 {} | null | undefined;
18 }
19
20 function stringify(obj?: ParsedUrlQueryInput, sep?: string, eq?: string, options?: StringifyOptions): string;
21 function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
22 /**
23 * The querystring.encode() function is an alias for querystring.stringify().
24 */
25 const encode: typeof stringify;
26 /**
27 * The querystring.decode() function is an alias for querystring.parse().
28 */
29 const decode: typeof parse;
30 function escape(str: string): string;
31 function unescape(str: string): string;
32}