Repository navigation
fix(types): add capture variants of toggle, dialog and command events - #5387
Merged
JoviDeCroock merged 2 commits intoNov 19, 2026
Merged
JoviDeCroock merged 2 commits into
JoviDeCroock merged 2 commits into
Conversation
Preact registers any `on*Capture` prop as a capturing listener, but `DOMAttributes` and `DialogHTMLAttributes` had no capture variant for `onBeforeToggle`, `onToggle`, `onCancel`, `onClose` and `onCommand`, so they failed to type-check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rschristian
reviewed
Nov 19, 2026
Comment on lines
+347
to
+350
|
|
||
| // Capture variants of popover, dialog and command events, which Preact | ||
| // registers with `addEventListener(name, handler, true)` | ||
| const testCaptureEvents = ( |
Member
There was a problem hiding this comment.
Delete these tests, they're not useful. All they test is that we don't delete the interface members which... why would we?
Adding tests for every single basic property add is just noise.
Contributor
Author
There was a problem hiding this comment.
Removed in efbf8cf, the PR now only touches src/dom.d.ts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JoviDeCroock
approved these changes
Nov 19, 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.
AI disclosure: I used Claude Code (an LLM coding agent) to write this change and this description. I checked the result myself, as described below. This replaces #5333, which I opened without a disclosure and which was closed under the Code of Conduct. Sorry about that. This version is also smaller: it only adds lines, and it leaves out the reordering and the
closedbymove that were in #5333.Problem
Preact turns any
on*Captureprop into a capturing listener (src/diff/props.jsstrips theCapturesuffix and passesuseCapturetoaddEventListener). The types have no capture variant for these handlers, so each of these lines fails to type-check onmain:The error is
TS2322: Type '{ onToggleCapture: ... }' is not assignable to type 'DetailsHTMLAttributes<HTMLDetailsElement>', and the same for the others.Change
DOMAttributes: addonBeforeToggleCaptureandonToggleCapture(ToggleEventHandler),onCloseCaptureandonCancelCapture(GenericEventHandler), andonCommandCapture(CommandEventHandler), next to the existing non-capture handlers.DialogHTMLAttributes: addonCancelCaptureandonCloseCapturenext to its existingonCancelandonClose.Verification
newState,oldState,command,currentTarget.returnValue). Againstmain'ssrc/dom.d.tsthat fails with 10 errors (4 × TS2322 and 6 × TS7006); with this change it passes. The test block was removed after review.pnpm test:ts(core and compat),pnpm lintandpnpm buildpass.pnpm test:vitest:minpasses: 110 files, 1484 tests.oxfmt --check .reportscompat/test/ts/index.tsxanddebug/test/browser/debug.test.jsx. This PR does not touch either file.🤖 Generated with Claude Code