Generics in @Input?

  • 0
    Is it possible to use generics in inputs? From the fact that I googled all the solutions are too complimentary. How do you type props for reusable components?
    JavaScript August Flowers, Apr 18, 2020

  • 1 Answers
  • 0
    From the point of view of typescript, there are no inputs, these are ordinary public fields.

    Generics as usual, the class defines a variable type and it can be extended to fields.



    class MyComponent<T> {
    @Input() prop: T;
    }
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!