Relative Content

Tag Archive for typescripttypescript-genericstypescript-5

TypeScript: Match value and handler based on shared key

I store data in objects with different versions that use different keys and different types.
The acceptable types for the data properties are defined in an interface that defines the versions as a dictionary type.
I want to match the object with handler functions based on a matching key in the data.
I create an dictionary value of handlers that stores the functions indexed by the associated key.