A utility type that constructs a widget map from a "registry interface".
The keys of the registry should be the widget type (aka, "categorizer" or
"radio", etc) and the value should be the option type stored in the value
of the map.
You can think of this as a type that generates another type. We use
"registry interfaces" as a way to keep a set of widget types to their data
type in several places in Perseus. This type then allows us to generate a
map type that maps a widget id to its data type and keep strong typing by
widget id.
For example, given a fictitious registry such as this:
We use interfaces for the registries so that they can be extended in cases
where the consuming app brings along their own widgets. Interfaces in
TypeScript are always open (ie. you can extend them) whereas types aren't.
A utility type that constructs a widget map from a "registry interface". The keys of the registry should be the widget type (aka, "categorizer" or "radio", etc) and the value should be the option type stored in the value of the map.
You can think of this as a type that generates another type. We use "registry interfaces" as a way to keep a set of widget types to their data type in several places in Perseus. This type then allows us to generate a map type that maps a widget id to its data type and keep strong typing by widget id.
For example, given a fictitious registry such as this:
If we create a DummyMap using this helper:
We'll get a map that looks like this:
We use interfaces for the registries so that they can be extended in cases where the consuming app brings along their own widgets. Interfaces in TypeScript are always open (ie. you can extend them) whereas types aren't.