How to get Type of Array in TypeScript generics
09:14 14 Dec 2018

I have a method like this:

public select(fieldName: keyof TType)

Where TType could be an array type. In case of an array type, fieldName will correctly offer me all the propertynames of type Array.

In case I call this method with a type of User[], I want to get to the properties of User instead of the properties of Array.

Is there a way of how this could be done?

Extra question: Is there a way to restrict TType to be of an array type?

typescript