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 should have type string | undefined #51431

Closed
markfields opened this issue Nov 7, 2022 · 2 comments
Closed

JSON.stringify should have type string | undefined #51431

markfields opened this issue Nov 7, 2022 · 2 comments

Comments

@markfields
Copy link
Member

Bug Report

πŸ”Ž Search Terms

stringify, JSON.stringify undefined

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about stringify

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

// hover over 'x', it's typed as string.
const x = JSON.stringify(undefined);
console.log(typeof x)  // outputs "undefined"

πŸ™ Actual behavior

Return type of JSON.stringify is string but it can return undefined

πŸ™‚ Expected behavior

Return type should reflect actual set of values that could be returned: string | undefined

@IllusionMH
Copy link
Contributor

Duplicate of #18879

Ton of duplicates can be found with search for JSON.stringify undefined

@markfields
Copy link
Member Author

Sure enough! I adjusted my query to include quotes and found the one you linked right away. Closing.

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