question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Declared Types cannot include Keywords as Properties

See original GitHub issue

Present 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:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
msujewcommented, Jun 22, 2022
1reaction
msujewcommented, Jun 22, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found