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

✨ Use JsonValue instead of unknown #121

Closed
wants to merge 10 commits into from
Closed

✨ Use JsonValue instead of unknown #121

wants to merge 10 commits into from

Conversation

aaditmshah
Copy link

Both JSON.parse and .json() currently return unknown. This type is too general. We can use the more specific JsonValue type here. This allows users to consume the return value of these functions without having to use zod. However, users are still encouraged to validate and parse the result into another type since JsonValue is difficult to use.

type JsonValue = string | number | boolean | JsonValue[] | JsonObject | null;

type JsonObject = { [key: string]: JsonValue };

@mattpocock
Copy link
Collaborator

See #10

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.

None yet

2 participants