Repository navigation
Preserve type-guard narrowing in query functions - #2379
iamabhisheknag wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Low impact] The PR appears safe to merge; no blocking issues were found.
|
Calls such as
filter(isText, nodes).map(node => node.data)currently lose type-guard narrowing, so TypeScript rejects access to narrowed node properties;find(),findOne()andfindAll()likewise discard predicate narrowing.Add type predicate overloads that preserve the narrowed node result, alongside the existing boolean predicate signatures. Tests cover element/text guards, narrowed element types, boolean callbacks, recursion, and limits.
Validation:
npm testpasses all 94 tests plus ESLint, TypeScript and Biome checks;npm run buildpasses. The new type checks fail before the overloads are added. Transpiled runtime JavaScript is identical with comments removed.AI assistance: OpenAI coding assistant (GPT-6).
Summary by CodeRabbit