Is it possible to constrain the type of an input parameter to a generic Typescript function to be a Typescript enum?
In other words, I want to enforce that T in the
You can constrain the type to a specific enum.
function foo(param: T) { }
However, you cannot constrain it to be any enum (see specs).
In addition to generic interfaces, we can also create generic classes. Note that it is not possible to create generic enums and namespaces.