diff --git a/src/entrypoints/json-parse.d.ts b/src/entrypoints/json-parse.d.ts index c6306dc..e4ba8f0 100644 --- a/src/entrypoints/json-parse.d.ts +++ b/src/entrypoints/json-parse.d.ts @@ -1,12 +1,20 @@ interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. + * @param value A valid JSON string or null. * @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. */ parse( - text: string, + value: string, + reviver?: (this: any, key: string, value: any) => any, + ): unknown; + parse( + value: null, + reviver?: (this: any, key: string, value: any) => any, + ): null; + parse( + value: string | null, reviver?: (this: any, key: string, value: any) => any, ): unknown; } diff --git a/src/tests/json-parse.ts b/src/tests/json-parse.ts index 45f1c27..5978204 100644 --- a/src/tests/json-parse.ts +++ b/src/tests/json-parse.ts @@ -12,3 +12,16 @@ doNotExecute(() => { // @ts-expect-error const result = JSON.parse("{}"); }); + +doNotExecute(() => { + const result = JSON.parse(null); + + type tests = [Expect>]; +}); + +doNotExecute(() => { + const func = (): string | null => null; + const result = JSON.parse(func()); + + type tests = [Expect>]; +});