Skip to content

Generate more const in ast.ts #2045

@cdietrich

Description

@cdietrich

it would be nice to have consts to be generated for additional stuff in the grammar.

  1. 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]
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions