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
This commit is contained in:
Chris Shaffer
2019-05-28 12:21:54 -07:00
committed by Sheetal Nandi
parent 04031dd4ae
commit 32db7fc4ed
2 changed files with 22 additions and 6 deletions
+11 -3
View File
@@ -12,13 +12,21 @@ declare module "querystring" {
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;
// 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;
}
+11 -3
View File
@@ -12,13 +12,21 @@ declare module "querystring" {
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;
// 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;
}