How to infer/map types dynamically from a given array of objects?
I have an array of objects something like this:
How to extend narrow type inference to every property of an object?
Suppose a “dependent function” (type DepFunc) is a simple object with property deps
whose value is an arbitrary simple object (the keys of which are the “dependencies”), and a property build
whose value is a function that takes an object with the same keys as deps
and returns a function from number to number; OR a dependent function could be just a function from number to number in the trivial case of no dependencies. This type seems well captured by
TypeScript Generic Pick with Partial allows to pick non existing properties
I want to use Pick<Type, Keys>
generically, so I could retrieve keys dynamically ONLY if those exist on the provided Type
.
Correct typing when creating a collection where the elements are made up of different instantiations of the same generic function
I’m trying to create an object where the values are all different instantiations of the same generic. I also want to have the type inferred since this collection is meant to contain at least 100 elements. I’m running into some weird typing situations. I started with this: