From my point of view, the types of the $container properties could be more precise, i.e. only Student for OneValue and only Teacher for TwoValues.
The current $container types are not wrong, but as a user of Langium, I would expect the following types, since the grammar clearly shows, that these types are enough:
The following simple and artificial example uses guard conditions in order to switch between different cases (excerpt):
(The whole grammar with an instance can be found in the playground.)
For this grammar, Langium generates the following types in the
ast.ts
(excerpt):From my point of view, the types of the
$container
properties could be more precise, i.e. onlyStudent
forOneValue
and onlyTeacher
forTwoValues
. The current$container
types are not wrong, but as a user of Langium, I would expect the following types, since the grammar clearly shows, that these types are enough: