Skip to content

Forward Reference Validation #632

Answered by msujew
snarkipus asked this question in Q&A
Aug 13, 2022 · 1 comments · 11 replies
Discussion options

You must be logged in to vote

Hey @snarkipus,

multiple thoughts on this:

  1. We actually implement a getContainerOfType function in Langium, which is typed a bit better than yours. You can use it like this:
const abstractElement = getContainerOfType(e, isAbstractElement); // Through typescript magic, `abstractElement` is automatically typed as `AbstractElement | undefined`
  1. Your getContainerOfType function actually uses null. We don't use null usually in Langium, but undefined instead. They have different semantic meanings (usually), and also behave differently in equality checks or typeof checks. See also this.
  2. I believe this relatively simplistic way of finding previous variables stops working once you start working o…

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@msujew
Comment options

@snarkipus
Comment options

snarkipus Aug 17, 2022
Collaborator Author

@snarkipus
Comment options

snarkipus Aug 17, 2022
Collaborator Author

@msujew
Comment options

@snarkipus
Comment options

snarkipus Aug 18, 2022
Collaborator Author

Answer selected by snarkipus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants