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 stricter type for JsonObject #52

Closed
gajus opened this issue Nov 12, 2021 · 2 comments
Closed

Use stricter type for JsonObject #52

gajus opened this issue Nov 12, 2021 · 2 comments

Comments

@gajus
Copy link

gajus commented Nov 12, 2021

JsonObject that comes from 'type-fest' (annoyingly) includes undefined as valid value, which is not the case for json.

A better definition would be:

type JsonObject = { [key: string]: JsonValue, };
type JsonValue = JsonObject | JsonValue[] | boolean | number | string | null;
gajus added a commit to gajus/roarr that referenced this issue Nov 12, 2021
@sindresorhus
Copy link
Owner

JsonObject that comes from 'type-fest' (annoyingly) includes undefined as valid value

It does not. It allows optional keys. You might want to use the exactOptionalPropertyTypes flag.

@sindresorhus
Copy link
Owner

Context: sindresorhus/type-fest#65

@gajus gajus closed this as completed Nov 13, 2021
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

No branches or pull requests

2 participants