From a8df0dd575a81f2a0e2c4e9163503456b0c9cd32 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Mon, 14 Oct 2019 08:52:25 -0700 Subject: [PATCH] Make typing of MakiObjects more explicit --- modern/src/utils.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modern/src/utils.ts b/modern/src/utils.ts index 0cfb4792..308954e8 100644 --- a/modern/src/utils.ts +++ b/modern/src/utils.ts @@ -287,9 +287,7 @@ function findDirectDescendantById< ); } -function* iterateLexicalScope< - T extends { children: T[]; parent: T | undefined } ->(node: T): IterableIterator { +function* iterateLexicalScope(node: MakiObject): IterableIterator { 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( - 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;