TokenKind — simplified enum paralleling Spring TokenKind
Each token type has one value in this enum.
Note: some semantics (e.g. isKeyword) are determined in the Token class directly.
Every member carries an explicit ordinal. The enum is published, and TypeScript
compiles a numeric enum into a runtime object with a reverse map, so the ordinals
are part of the shipped ABI: a consumer that stores one, or reads TokenKind[14],
observes them. A member declared without a value takes "one more than the previous
member", which silently renumbers every member after it — adding DIV among the
operators did exactly that, moving MOD from 14 to 15 and EOF from 53 to 54
between the published 1.2.2 and the 2.0.0 candidate. The values are therefore
written out, and tests/unit/token-kind-stability.test.ts pins the whole table so
that a future insertion cannot renumber the enum again.
TokenKind — simplified enum paralleling Spring TokenKind
Each token type has one value in this enum. Note: some semantics (e.g. isKeyword) are determined in the Token class directly.
Every member carries an explicit ordinal. The enum is published, and TypeScript compiles a numeric enum into a runtime object with a reverse map, so the ordinals are part of the shipped ABI: a consumer that stores one, or reads
TokenKind[14], observes them. A member declared without a value takes "one more than the previous member", which silently renumbers every member after it — addingDIVamong the operators did exactly that, movingMODfrom 14 to 15 andEOFfrom 53 to 54 between the published 1.2.2 and the 2.0.0 candidate. The values are therefore written out, andtests/unit/token-kind-stability.test.tspins the whole table so that a future insertion cannot renumber the enum again.