fix: Attribute.JSON type matches RFC 4627 (#18683)

This commit is contained in:
Ben Irvin 2023-11-17 10:55:57 +01:00 committed by GitHub
parent 50ae047484
commit d30e85155f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,14 @@ export type JSON = Attribute.OfType<'json'> &
Attribute.VisibleOption &
Attribute.DefaultOption<JsonValue>;
export type JsonValue<T extends object = object> = T;
type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
type JSONArray = Array<JSONValue>;
interface JSONObject {
[key: string]: JSONValue;
}
export type JsonValue<T extends JSONValue = JSONValue> = T;
export type GetJsonValue<T extends Attribute.Attribute> = T extends JSON ? JsonValue : never;