Typescript has a couple of types which are useful for describing types when none are strictly specified.
Let’s assume we have this simple function, which takes a string parameter and returns
function getData(key: string) {
return { key, firstName: "Scooby", lastName: "Doo" }
}
Using ReturnType creates a type that matches the getData return. i.e. { key: string, firstName: string, lastName: string } whereas the Parameters will be a tuple [key: string]
type T = ReturnType<typeof getData>; type T = Parameters<typeof getData>;