Note: This question is specifically regarding the TypeScript compiler API and not the TypeScript language itself!
I have a value that is of type ts.Type
. My goal is to understand what kind of type it actually represents. Is it a number, a function, or perhaps an array?
After exploring, I discovered that by accessing type.flags
, I can somewhat mimic the behavior of the static typeof
operator. This helps me distinguish between primitive types like number
, string
, and boolean
(excluding functions). Anything other than those primitives - such as arrays, functions, plain old JavaScript objects, etc. - will simply have the TypeFlags.Object
flag.
My query now is: How can I delve deeper into these non-primitive types? What methods can I use to identify whether a type is an array, a function, an enum, a class instance, and so on?