Skip to content

JSON.stringify should have type string | undefinedΒ #51431

Closed
@markfields

Description

@markfields

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions