I may have missed something in the docs, but I can't find any way in typescript to get the types of the parameters in a function. That is, I've got a function
function test(a: string, b: number) {
console.log(a);
console.log(b)
}
I want access to the types string
and number
, likely as a tuple.
I know I can get the type of the function itself, as typeof test
, or the return type via ReturnType<test>
.
When I tried keyof typeof test
, it returned never
, which I also couldn't explain.
Other answers like this one point to extends
, but I don't really understand how that works and don't give me an easy way to access the set-of-all-params as a type.
string
froma
andnumber
fromb
? – Karolinekaroly[string, number]
or similar (a tuple, perhaps) from applying some sort of operation to the functiontest
– Arrangement