TypeScript supports Pick
to allow you to get a "subset" object type of a given type, but there is no built-in Pick
for deeper nested fields.
If you have a function that takes a large object as argument, but you don't use all of its fields, you can use Pick
, Pick2
, Pick3
, etc to narrow down the input type to be only just what you need. This will make it easier to test your function, because when mocking the input object, you don't need to pass all fields of the "large" object.
Hi! Nice project, it seems very well documented. I also released this typescript util as a library https://github.com/staltz/ts-multipick
Cheers