Closed JohannesMeierSE closed 2 weeks ago
Thanks @msujew for your review! I created two functions, one to be used at runtime and the other one at development time.
However, there are already test cases which check the generated code for data type rules with return type: https://github.com/eclipse-langium/langium/blob/main/packages/langium-cli/test/generator/ast-generator.test.ts#L170 But I don't understand, why they didn't show the regression.
Any ideas?
@JohannesMeierSE These tests don't test the generated property types. For example:
Value: id=ID;
ID returns string: ...;
is supposed to generate:
export interface Value extends AstNode {
id: ID // <-- this is the part that broke
}
export type ID = string;
Thanks for the suggestion @msujew! I added two test cases which test properties with data types which have an explicit return type.
This PR contributes:
This issue was found in a real-world application, where a data type rule (with
returns number
) which referred to a terminal rule (withreturns number
) produced astring
value at runtime in the AST (while the generated property in the TypeScript interface had the correct typenumber
). This conforms to the "number case" in the new test case. The cases for string and boolean are added only to be more complete.This issue is not related to https://github.com/eclipse-langium/langium/pull/1478.