TIP: SyntaxKind enum
Last updated
Was this helpful?
Last updated
Was this helpful?
SyntaxKind
is defined as a const enum
, here is a sample:
It's a const enum
(a concept ) 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: