Allow specifying props for top node created by Tree.build #8

Closed
not-my-profile wants to merge 1 commit from topProps into main
not-my-profile commented 2024-10-03 06:37:05 +02:00 (Migrated from github.com)
No description provided.
marijnh commented 2024-10-03 09:47:32 +02:00 (Migrated from github.com)

Is it not easy enough to, after calling Tree.build, use new Tree(tree.type, tree.children, tree.positions, tree.length, myProps) to create the tree with props you're looking for?

Is it not easy enough to, after calling `Tree.build`, use `new Tree(tree.type, tree.children, tree.positions, tree.length, myProps)` to create the tree with props you're looking for?
not-my-profile commented 2024-10-04 05:25:12 +02:00 (Migrated from github.com)

Oh yeah I didn't think of that. I think the API would compose better if there was a type for the content of a tree (children, positions, length), be it TreeContent ... then we could have TreeContent.build() and the Tree constructor could take just type, content and props and we wouldn't have to pass a topID to a function that doesn't actually care about it or do such a ring-around-the-rosy dance. But yeah this is probably not important enough to warrant such a breaking change.

Oh yeah I didn't think of that. I think the API would compose better if there was a type for the content of a tree (children, positions, length), be it `TreeContent` ... then we could have `TreeContent.build()` and the Tree constructor could take just type, content and props and we wouldn't have to pass a `topID` to a function that doesn't actually care about it or do such a ring-around-the-rosy dance. But yeah this is probably not important enough to warrant such a breaking change.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/common!8
No description provided.