I have some methods in TypeScript that are passed functions like getJson. In the application, this is an actual getJson function that does what it implies, but for testing purposes, getJson is mocked with a function that is the same shape as the original getJson.
I'm creating a type for these dependencies that currently looks like this:
import { getJson } from 'get-json';
interface Dependencies {
getJson: typeof getJson;
... others ...
}
This works great, but I have quite a few dependencies and may need to add more, and there's a lot of redundancy with typing the function name and then typeof -function- again.
Is there any way to create the type that is an object with keys that match the function names whose values are the functions?
dependenciesobject of the shape you are looking for, using shorthand property names... and then get that object's type.. like this, maybe.