Skip to content

Commit 04be41c

Browse files
author
Jonas Schürmann
authored
lib.d.ts: Include undefined in return type of JSON.stringify()
JSON.stringify() may return undefined if the given input value is undefined or if the input value is not serializable (like `function(){}`). See #18879
1 parent a7fa187 commit 04be41c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib/es5.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,14 +943,14 @@ interface JSON {
943943
* @param replacer A function that transforms the results.
944944
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
945945
*/
946-
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
946+
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string | undefined;
947947
/**
948948
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
949949
* @param value A JavaScript value, usually an object or array, to be converted.
950950
* @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.
951951
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
952952
*/
953-
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
953+
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string | undefined;
954954
}
955955

956956
/**

0 commit comments

Comments
 (0)