Include Comment nodes in polyfill hook types - #691
Open
olavoasantos wants to merge 1 commit into
Open
olavoasantos wants to merge 1 commit into
olavoasantos wants to merge 1 commit into
Conversation
olavoasantos
force-pushed
the
type-comment-hooks
branch
from
September 3, 2026 15:30
7ec4250 to
d270be2
Compare
olavoasantos
force-pushed
the
type-comment-hooks
branch
from
September 4, 2026 14:31
d270be2 to
08e3223
Compare
olavoasantos
marked this pull request as ready for review
September 4, 2026 15:29
marvinhagemeister
approved these changes
Sep 15, 2026
JoviDeCroock
approved these changes
Sep 15, 2026
henrytao-me
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The polyfill invokes text and child-mutation hooks for
Commentnodes at runtime, but the correspondingHooksTypeScript signatures accepted onlyTextnodes. The public type contract therefore rejected a runtime-supported node kind.Impact
Minor. TypeScript consumers implementing
setText,insertChild, orremoveChildcould not accurately type their handling of comments. This is type-contract drift rather than a runtime failure, but it can force unsafe casts or make valid hook implementations fail type checking.Reproduction
The added regression test verifies that runtime calls already pass the
Commentnode toinsertChild,setText, andremoveChild. Before this change, the type-level assertions that aDocument['createComment']result is accepted by those hook parameter types failed; they now pass.Change
Widen the affected hook parameters from
TexttoText | Comment, matching the nodes the polyfill already supplies at runtime. No hook dispatch behavior changes.Tests
Adds compile-time assertions for comment compatibility with all three hook signatures, plus runtime spies that verify insertion, text updates, and removal receive the comment node and expected payloads.
Stack
normalize-text-node-hooksValidation
Fresh GitHub CI on restacked head
08e3223passes: