DefinitelyTyped/types/node/querystring.d.ts
Chris Shaffer 32db7fc4ed Add missing types for aliases querystring.encode and querystring.decode to v12 & v11 (#35694)
* Added definitions - encode & decode aliases

These have existed since @ least v10 and are documented here: https://nodejs.org/api/querystring.html

* corrected order of comments for encode & decode

* Added definitions for encode & decode aliases

These have existed since at least v10 and are documented here:  https://nodejs.org/api/querystring.html

* corrected 'ParsedUrlQueryInput' & jsdoc comments

* Corrected jsdoc alignment

* Corrected jsdoc comment

* refactored encode and decode aliases with typeof
2019-05-28 12:21:54 -07:00

33 lines
1.1 KiB
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;
/**
* The querystring.encode() function is an alias for querystring.stringify().
*/
const encode: typeof stringify;
/**
* The querystring.decode() function is an alias for querystring.parse().
*/
const decode: typeof parse;
function escape(str: string): string;
function unescape(str: string): string;
}