From eb70258db2c822f55588b3c0eca38a5a3948611e Mon Sep 17 00:00:00 2001 From: Aluan Haddad Date: Tue, 6 Feb 2018 15:26:32 -0500 Subject: [PATCH] improve the type of the stringify function Update the stringify function based on the declarations in `lib.es5.d.ts` for JSON.parse. Add the documentation taken from `lib.es5.t.ts` --- types/comment-json/index.d.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/types/comment-json/index.d.ts b/types/comment-json/index.d.ts index 9c2652f34e..09ed176ac5 100644 --- a/types/comment-json/index.d.ts +++ b/types/comment-json/index.d.ts @@ -4,5 +4,19 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export type Reviver = (k: number | string, v: any) => any; + +/** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param json A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ export function parse(json: string, reviver?: Reviver, removes_comments?: boolean): any; -export function stringify(value: any, replacer?: any, space?: string | number): string; + +/** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results or an array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ +export function stringify(value: any, replacer?: ((key: string, value: any) => any) | (number | string)[] | null, space?: string | number): string;