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`
This commit is contained in:
Aluan Haddad
2018-02-06 15:26:32 -05:00
committed by GitHub
parent a593fd2d60
commit eb70258db2
+15 -1
View File
@@ -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;