From 32db7fc4ed4474c29518987b7e50da6ded02880b Mon Sep 17 00:00:00 2001 From: Chris Shaffer Date: Tue, 28 May 2019 14:21:54 -0500 Subject: [PATCH] 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 --- types/node/querystring.d.ts | 14 +++++++++++--- types/node/v11/querystring.d.ts | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/types/node/querystring.d.ts b/types/node/querystring.d.ts index 39ae8f54e4..23359d9ded 100644 --- a/types/node/querystring.d.ts +++ b/types/node/querystring.d.ts @@ -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; } diff --git a/types/node/v11/querystring.d.ts b/types/node/v11/querystring.d.ts index 39ae8f54e4..23359d9ded 100644 --- a/types/node/v11/querystring.d.ts +++ b/types/node/v11/querystring.d.ts @@ -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; }