-
Notifications
You must be signed in to change notification settings - Fork 338
Open
Labels
Description
Describe the bug
Hello!
I'm struggling with the following piece of tsp:
model Object {
@visibility(Lifecycle.Read)
@key id: string,
}
model Item extends Object {
name: string,
// other props...
}
@doc("An excerpt of Item for Account")
model Account_Item is PickProperties<Item, "id" | "name">;
model Account extends Object {
@visibility(Lifecycle.Read)
item: Account_Item,
// item: PickProperties<Item, "id" | "name">,
@visibility(Lifecycle.Create, Lifecycle.Update)
// item_id: Account_Item.id, // <------------ ERR: Model doesn't have member id
item_id: Item.id, // <------------ ERR: Duplicate type name: 'Account'
}
// below should go definitions using Create<Account>, Update<Account> hence lifecycles.Both kinds of definition of item_id seem to be evident to me, but they result in throwing errors (see comments).
Both errors seem a bit inadequate to me, esp. "Duplicate type name: 'Account'".
Am I doing something fundamentally wrong?
How else to express a model property that is an id of another model and must be visible at create/update lifecycle only?
TIA
Reproduction
model Object {
@visibility(Lifecycle.Read)
@key id: string,
}
model Item extends Object {
name: string,
// other props...
}
@doc("An excerpt of Item for Account")
model Account_Item is PickProperties<Item, "id" | "name">;
model Account extends Object {
@visibility(Lifecycle.Read)
item: Account_Item,
// item: PickProperties<Item, "id" | "name">,
@visibility(Lifecycle.Create, Lifecycle.Update)
// item_id: Account_Item.id, // <------------ ERR: Model doesn't have member id
item_id: Item.id, // <------------ ERR: Duplicate type name: 'Account'
}
// below should go definitions using Create<Account>, Update<Account> hence lifecycles.Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable