Skip to content

fix: JSON.parse accepting null - #174

Open
ImLunaHey wants to merge 1 commit into
mattpocock:mainfrom
ImLunaHey:main
Open

fix: JSON.parse accepting null#174
ImLunaHey wants to merge 1 commit into
mattpocock:mainfrom
ImLunaHey:main

Conversation

@ImLunaHey

Copy link
Copy Markdown

Please let me know if I missed anything in this.

Fixes: #173

@qb20nh

qb20nh commented Jan 23, 2024

Copy link
Copy Markdown

Argument name should not change.

@ImLunaHey

ImLunaHey commented Jan 23, 2024

Copy link
Copy Markdown
Author

it should never have been called text to begin with. it's a value.

@qb20nh

qb20nh commented Jan 24, 2024

Copy link
Copy Markdown

That is not a typescript issue.

@qb20nh

qb20nh commented Jan 25, 2024

Copy link
Copy Markdown

For completeness and consistency, we should generalize to all valid JSON string producing text values.

parse<T extends boolean | number | bigint>(text: T, /*...*/): T
parse<T extends boolean | number | bigint | null>(text: T, /*...*/): unknown

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

Successfully merging this pull request may close these issues.

allow passing null to JSON.parse()

2 participants