langium
langium copied to clipboard
Generate more const in ast.ts
it would be nice to have consts to be generated for additional stuff in the grammar.
- keywords
we currently generate
export namespace <grammar> {
export type KeywordNames =
| "x"
| "y"
| "z";
}
it would be nice to have access to the keywords list at runtime too
export const KeywordNames = ["x", "y", "z"] as const
export type KeywordNames = (typeof KeywordNames)[number]
- types (am not sure about this)
grammar:
type MyFakeEnum = 'A' | 'B' | 'C';
interface MyIf {
name: MyFakeEnum;
}
generates
export type MyFakeEnum = 'A' | 'B' | 'C';
export interface MyIf extends langium.AstNode {
readonly $type: 'MyIf';
name: MyFakeEnum;
}
having a way to have the possible values of MyFakeEnum available at runtime would be nice too.
originally reported here https://github.com/eclipse-langium/langium/pull/1979#issuecomment-3228415983
cc @JohannesMeierSE @joao-silveira