Skip to content

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
Owner

See #10

@mattpocock mattpocock closed this Mar 23, 2023
@aaditmshah aaditmshah deleted the feature/json-value branch March 23, 2023 12:48
@aaditmshah aaditmshah restored the feature/json-value branch March 23, 2023 16:24
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.

2 participants