Skip to content

Revert "Add undefined to JSON.stringify return type (#51897)"#52307

Merged
sandersn merged 3 commits intomicrosoft:mainfrom
sandersn:revert-51897
Jan 19, 2023
Merged

Revert "Add undefined to JSON.stringify return type (#51897)"#52307
sandersn merged 3 commits intomicrosoft:mainfrom
sandersn:revert-51897

Conversation

@sandersn
Copy link
Member

This reverts commit c7f49bc because of breaks like these found in github repositories:

function x(obj: object, key: string) {
    encodeURIComponent(JSON.stringify(obj[key as keyof typeof obj]))
}
function y(value: string) {
    if (typeof value !== 'string') {
        value = JSON.stringify(value)
    }
}
function z(file: PathOrFileDescriptor, obj: any, options: WriteFileOptions) {
    writeFileSync(file, JSON.stringify(obj, options?.replacer, options?.spaces), options)
}

(The last example depends on @types/fs-extra)

Discussed at the January 18 design meeting.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jan 19, 2023
@sandersn sandersn merged commit ecaf6d9 into microsoft:main Jan 19, 2023
@ecyrbe
Copy link

ecyrbe commented Jan 21, 2023

Will another fix for undefined be attempted ?

@sandersn sandersn deleted the revert-51897 branch January 23, 2023 22:54
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants