Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON.stringify can return undefined #59616

Closed
farnoy opened this issue Aug 13, 2024 · 1 comment
Closed

JSON.stringify can return undefined #59616

farnoy opened this issue Aug 13, 2024 · 1 comment

Comments

@farnoy
Copy link

farnoy commented Aug 13, 2024

⚙ Compilation target

ES2018

⚙ Library

es2018

Missing / Incorrect Definition

JSON.stringify always returns string

stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;

But JSON.stringify(undefined) returns undefined

Sample Code

const whatever: string | undefined = `JSON.stringify(undefined)`;

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#return_value

@jcalz
Copy link
Contributor

jcalz commented Aug 13, 2024

Duplicate #18879

See #18879 (comment)

@farnoy farnoy closed this as completed Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants