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.

Support for properties in the parent type

See original GitHub issue

Unassigned rule calls create a parent-child relation, and in the example below, AbstractToken is a parent of TokenA, TokenB and TokenC. AbstractToken also has own property cardinality.

AbstractToken:
  ( TokenA
  | TokenB
  | TokenC
  ) cardinality=('?'|'+'|'*')?;

However, types generation only reflects reflects ownership, not inheritance. Generated types:

export interface AbstractToken extends AstNode {
    cardinality?: '*' | '+' | '?'
}

// similar to `TokenB` and `TokenC`
export TokenA extends AstNode {
	...
}

Since inheritance is reflected by union type for the purpose of property lifting, we should generate the types in the above case as follows:

export type AbstractToken = (TokenA | TokenB | TokenC) & { cardinality?: '*' | '+' | '?' }

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
pluraliacommented, May 23, 2022

We could simply decide not to do any property lifting ourselves here and see whether it’s a real problem in languages that have such constructs. WDYT?

Yes, that makes sense. At least we can take a pause to think more about it. I move the milestone.

0reactions
spoenemanncommented, May 23, 2022

we have to manually lift the children properties, and thus we go back to necessity to implement an algorithm that lifts properties.

@pluralia I think now I understood what you mean. But nobody forces us to do this lifting, it’s really just a convenience feature. We could simply decide not to do any property lifting ourselves here and see whether it’s a real problem in languages that have such constructs. WDYT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript not recognizing properties on the parent class?
Since not all versions of TypeScript support abstract properties directly, this solution should work in any case: export abstract class ...
Read more >
Inheritance - CSS: Cascading Style Sheets - MDN Web Docs
CSS properties can be categorized in two types: inherited properties, which by default are set to the computed value of the parent element ......
Read more >
AccessibleObject.Parent Property (System.Windows.Forms)
This code excerpt demonstrates overriding the Parent property. See the AccessibleObject class overview for the complete code example.
Read more >
Python Inheritance - W3Schools
Inheritance allows us to define a class that inherits all the methods and properties from another class. Parent class is the class being...
Read more >
How to optimize parent class property in sub class table
1) Create a same property in the child class with same as parent class. Optimize and delete the property from the child class....
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