sindresorhus / serialize-error

Serialize/deserialize an error into a plain object
MIT License
538 stars 63 forks source link

Use stricter type for JsonObject #52

Closed gajus closed 3 years ago

gajus commented 3 years ago

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;
sindresorhus commented 3 years ago

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 commented 3 years ago

Context: https://github.com/sindresorhus/type-fest/pull/65