Relative Content

Tag Archive for typescripttypescript-generics

Generic object interface with matching keys

I’m trying to make a generic interface to define a translation dictionary where the primary keys specify the language, and within each language the same keys are present.

Function that returns a tuple type from array of keys

I’m trying to construction a function where you pass an object, and an array of keys (This is a simplified example to illustrate what im trying to achieve). Then return is an array that contain those keys, and has the type of a tuple. The problem that I’m struggling with is that the return type is the union of all types in the interface, not the actual value of the given key.