They both share the same enum value e.g. from TypeScript 3.7.2:
VariableStatement = 224,
FirstStatement = 224,
Why are there two names for the same syntax kind?
In the SyntaxKind
enum, there are some entries which are used to denote not the concrete syntax kind, but a class of them. For statements, it is defined as following:
enum SyntaxKind {
// snip
FirstStatement = VariableStatement,
LastStatement = DebuggerStatement,
// snip
}
Then, to check if some syntax kind is one of the "statement" kinds, one can simply write kind >= SyntaxKind.FirstStatement && kind <= SyntaxKind.LastStatement
. And, if the set of statement kinds will ever change, only the definition of FirstStatement
or LastStatement
should be changed, not these "range checks".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With