TIP: SyntaxKind enum
SyntaxKind
is defined as a const enum
, here is a sample:
It's a const enum
(a concept we covered previously) so that it gets inlined (e.g. ts.SyntaxKind.EndOfFileToken
becomes 1
) and we don't get a dereferencing cost when working with the AST. However, the compiler is compiled with --preserveConstEnums
compiler flag so that the enum is still available at runtime. So in JavaScript you can use ts.SyntaxKind.EndOfFileToken
if you want. Additionally you can convert these enum members to display strings using the following function:
Last updated