Declared Types cannot include Keywords as Properties
See original GitHub issuePresent in Langium version: 0.4.0
We can currently generate AST types via inference that include various Langium keywords as properties, like so:
A: interface=ID type=ID grammar=ID;
infers…
export interface A extends AstNode {
grammar: string
interface: string
type: string
}
However, if cannot do the same via declared types. The following is an example demonstrating how this fails, but also shows that Langium is highlighting the properties incorrectly as keywords.
Unless we intend to remove these properties from being used via inference, we should also support them in their declared forms.
To solve this:
- we should be able to declare the same properties via inference as we can explicitly
- we should have a test verifying this behavior
- if we choose to block certain keywords, we’ll need extra tests guarding against those keywords (should we choose this route instead)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Purpose of declare keyword in TypeScript - Stack Overflow
TL;DR. declare is used to tell the compiler "this thing (usually a variable) exists already, and therefore can be referenced by other code, ......
Read more >required modifier - C# Reference - Microsoft Learn
The required modifier can be applied to fields and properties declared in struct , and class types, including record and record struct types....
Read more >Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >Properties - Manual - PHP
An obsolete way of declaring class properties, is by using the var keyword instead of a modifier. Note: A property declared without a...
Read more >Properties — The Swift Programming Language (Swift 5.7)
Because rangeOfFourItems is declared as a constant (with the let keyword), ... A Swift property doesn't have a corresponding instance variable, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@montymxb There’s a special data type rule that can be used to work around the
^
token:https://github.com/langium/langium/blob/207b6e59f063d04825ab77185cda1baa96b7ee25/packages/langium/src/grammar/langium-grammar.langium#L198-L199
You can always escape keywords using the
^
token at the start of the ID. But anway, we should use the appropriate data type rule for the names of properties.