mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 20:40:39 +00:00
Make typing of MakiObjects more explicit
This commit is contained in:
parent
d215c619f1
commit
a8df0dd575
1 changed files with 5 additions and 7 deletions
|
|
@ -287,9 +287,7 @@ function findDirectDescendantById<
|
|||
);
|
||||
}
|
||||
|
||||
function* iterateLexicalScope<
|
||||
T extends { children: T[]; parent: T | undefined }
|
||||
>(node: T): IterableIterator<T> {
|
||||
function* iterateLexicalScope(node: MakiObject): IterableIterator<MakiObject> {
|
||||
let currentNode = node;
|
||||
while (currentNode.parent) {
|
||||
const { parent } = currentNode;
|
||||
|
|
@ -306,10 +304,10 @@ function* iterateLexicalScope<
|
|||
}
|
||||
|
||||
// Search up the tree for a node that is in `node`'s lexical that matches `predicate`.
|
||||
function findInLexicalScope<T extends { children: T[]; parent: T | undefined }>(
|
||||
node: T,
|
||||
predicate: (node: T) => boolean
|
||||
): T | null {
|
||||
function findInLexicalScope(
|
||||
node: MakiObject,
|
||||
predicate: (node: MakiObject) => boolean
|
||||
): MakiObject | null {
|
||||
for (const child of iterateLexicalScope(node)) {
|
||||
if (predicate(child)) {
|
||||
return child;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue