-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Labels
astAST structure related issueAST structure related issuetypesTypes related issueTypes related issue
Description
When a parent has no own properties, we generate a type Parent
:
Parent:
ChildA | ChildB;
ChildA:
'a' a=NUMBER commonProp=ID;
ChildB:
'b' b=NUMBER commonProp=ID;
generates
export type Parent = ChildA | ChildB;
export interface ChildA extends AstNode {
a: number
commonProp: string
}
export interface ChildB extends AstNode {
b: number
commonProp: string
}
Besides, common children properties like commonProp
will be lifted automatically. However, as only a parent has own properties, we generate an interface Parent
:
Parent:
parentProp=ID (ChildA | ChildB);
// ChildA and ChildB are without changes
generates
export interface Parent extends AstNode {
parentProp: string
}
export interface ChildA extends AstNode {
a: number
commonProp: string
}
export interface ChildB extends AstNode {
b: number
commonProp: string
}
You can notice, that ChildA
and ChildB
don't extend Parent
and their commonProp
is not lifted in Parent
.
Langium version: 0.5.0
Package name: langium
The current behavior
Inferred Parent
-- ChildA
-- ChildB
hierarchy is wrong when Parent
has own properties (look above).
The expected behavior
export interface Parent extends AstNode {
parentProp: string
commonProp: string
}
export interface ChildA extends Parent {
a: number
}
export interface ChildB extends Parent {
b: number
}
The solution to the problem requires restoring properties lifting algorithm.
Metadata
Metadata
Assignees
Labels
astAST structure related issueAST structure related issuetypesTypes related issueTypes related issue