Although using a single type for both (SyntaxKind) is easier, it doesn’t make illegal states unrepresentable. For example, if I’m matching on a SyntaxKind produced by my lexer, I know that the kind cannot be one of SyntaxKind’s node variants, e.g. BinaryExpr. Similarly, when I’m deciding what kind to give a node, I shouldn’t be able to create a node of kind LetKw.
Although using a single type for both (
SyntaxKind
) is easier, it doesn’t make illegal states unrepresentable. For example, if I’mmatch
ing on aSyntaxKind
produced by my lexer, I know that the kind cannot be one ofSyntaxKind
’s node variants, e.g.BinaryExpr
. Similarly, when I’m deciding what kind to give a node, I shouldn’t be able to create a node of kindLetKw
.