Generated type from declared type does not include all of them #743
Unanswered
luan-xiaokun
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hey @luan-xiaokun, thanks for all the feedback. Yeah, as mentioned in the other discussions, declared types are still in active development. There is a lot going on behind the scenes regarding that topic. I believe the best way to address this topic by creating GitHub issues with reproducible examples. We can use later use those as test cases when we're getting to fixing them. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I'm using the declared types in the grammar definition and find something that somehow confuses me. #693 mentions that there are still some issues regarding the type declaration mechanism, and I want to know if the problem I'm having is one of them, or if there's something I haven't figured out yet. Thanks in advance.
Problems
TupleType
UnionType
andListType
are contained inType
. But in the generated typescript file, these types are missing, though they are still subtypes ofType
according to theisSubtype
function.Use the rule type 'X' instead of the typed rule name 'X' for cross references.
, which means that langium thinksX
refers to the typed parse rule instead of the declared type. I'm not sure if this error will occur when using type inference, but I found that (1) changing the name of the parse rule, or (2) put the type declaration & parse rule and cross reference in different files, can both solve this problem.However, there are two strange things:
TypeRule
as the parse rule name).Referenced rule "X" is not imported
. (This issuecheckGrammarTypeInfer
validation ignores declared types in other .langium files #728 seems to be relevant) This issue does not seem to be relevant to declared types, but I still include it in this discussion anyway.More background
The second and third problems came after I split a single grammar definition file into several, there are circular imports in these files, for example:
main
: import './A', './B', './interface',A
: import './main',B
: import './main',interface
: no import,where the
interface
file only includes interface and type declaration.#693 also suggests that the inference mechanism should be preferred currently, but I didn't see this advice until after I encountered these problems :( Currently there are about 60 interface declarations and 10 type definition in the
interface.langium
file.By the way, I think the title of the question is important because it can help others when searching for similar issues. But this discussion clearly contain several questions, what do you think is the best way to name this discussion?
Beta Was this translation helpful? Give feedback.
All reactions