In TypeScript, how can I statically extract the name of parameters?

61 Views Asked by At

In TypeScript, there's the Parameters<T> helper type, which allows the extraction of a labelled tuple type representing the parameters that a function expects. For instance:

function func(a: number, b: string) {}

type Args = Parameters<typeof func> // [a: number, b: string]

Is there a way to convert from this type to an object type? I.e., obtain this:

type ArgsAsObject = ??? // should be { a: number, b: string }
0

There are 0 best solutions below