0

I would like to get the input parameter of the class method as type in typescript. I try the code below:

class A {
    method(a: number){
        return a + a;
    }
}
type B = Parameters<A.method>

But no luck. Is there any method to extract the input parameter of the class method as type? Thank you.

Ken Yip
  • 599
  • 1
  • 8
  • 17
  • 2
    Hi @Ken Yip. It seems like this question was closed with a wrong duplicate target. Here is the correct answer: https://stackoverflow.com/questions/36311284/is-there-a-way-to-extract-the-type-of-typescript-interface-property. TLDR: use `A["method"]` – Tobias S. Nov 19 '22 at 22:46

0 Answers0