Skip to content

Commit

Permalink
Update JSON.stringify typings to handle all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chribjel committed Mar 7, 2024
1 parent 311c3f3 commit a9b624d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/entrypoints/json-stringify.d.ts
Expand Up @@ -10,7 +10,7 @@ interface JSON {
replacer?: (this: any, key: string, value: any) => any,
space?: string | number,
): T extends {} | null
? T extends () => void
? T extends (..._: any) => void
? undefined
: string
: T extends undefined
Expand All @@ -27,7 +27,7 @@ interface JSON {
replacer?: (number | string)[] | null,
space?: string | number,
): T extends {} | null
? T extends () => void
? T extends (..._: any) => void
? undefined
: string
: T extends undefined
Expand Down
7 changes: 7 additions & 0 deletions src/tests/json-stringify.ts
Expand Up @@ -41,6 +41,13 @@ doNotExecute(() => {
type tests = [Expect<Equal<typeof result, undefined>>];
});

doNotExecute(() => {
// create a something that is a function
const result = JSON.stringify(function (hello: any, world: any) {});

type tests = [Expect<Equal<typeof result, undefined>>];
});

doNotExecute(() => {
// create a something that is of type any
let toBeStringified: any;
Expand Down

0 comments on commit a9b624d

Please sign in to comment.