This PR aims to make the type of generated dataEnum slightly stricter by providing the second type parameter of Beet<T, V>.
When type V is missing, it defaults to Partial<T> which makes little sense in the case of a dataEnum since we've got to provide the __kind in order to know how to serialise it.
This causes issues when using dataEnum types in other types such as the map type which expect both its keys and values to be of type Beet<K, K> and Beet<V, V> respectively.
Here's an example.
Before
export const payloadTypeBeet = beet.dataEnum<PayloadTypeRecord>([
// ...
]) as beet.FixableBeet<PayloadType>;
When used in a map type, it throws a TypeError.
export const payloadBeet = new beet.FixableBeetArgsStruct<Payload>(
[['map', beet.map(payloadKeyBeet, payloadTypeBeet)]],
// ^-------------- TypeError: '__kind' is optional in type Partial<...>
'Payload',
);
This PR aims to make the type of generated
dataEnum
slightly stricter by providing the second type parameter ofBeet<T, V>
.When type
V
is missing, it defaults toPartial<T>
which makes little sense in the case of adataEnum
since we've got to provide the__kind
in order to know how to serialise it.This causes issues when using
dataEnum
types in other types such as themap
type which expect both its keys and values to be of typeBeet<K, K>
andBeet<V, V>
respectively.Here's an example.
Before
When used in a map type, it throws a TypeError.
After
Now the following type works.