Better typing for grammars

This commit is contained in:
barsdeveloper
2024-06-06 23:16:21 +02:00
parent ad4ba2c46d
commit 98ebdd78b2
40 changed files with 301 additions and 233 deletions

View File

@@ -29,12 +29,13 @@ export default class ObjectReferenceEntity extends IEntity {
)
).map(([full, type, path]) => new this(type, path, full))
static typeReferenceGrammar = this.typeReference.map(v => new this(v, "", v))
/** @type {P<ObjectReferenceEntity>} */
static grammar = P.alt(
this.fullReferenceSerializedGrammar,
this.fullReferenceGrammar,
this.typeReferenceGrammar,
).label("ObjectReferenceEntity")
static grammar = /** @type {P<ObjectReferenceEntity>} */(
P.alt(
this.fullReferenceSerializedGrammar,
this.fullReferenceGrammar,
this.typeReferenceGrammar,
).label("ObjectReferenceEntity")
)
#type
get type() {