Skip to content

Conversation

cszhjh
Copy link
Contributor

@cszhjh cszhjh commented Aug 25, 2025

For the other events marked in 13796 but not modified in this PR, I’m not sure whether they should also be updated. According to MDN, they were previously typed as MouseEvent, and I’m uncertain if changing them to PointerEvent could cause compatibility issues. For example: Click Event.

close #13796

Summary by CodeRabbit

  • Refactor
    • Tightened DOM event typings for JSX handlers: beforeinput → InputEvent, submit → SubmitEvent, auxclick/click/contextmenu → PointerEvent, abort → UIEvent, encrypted → MediaEncryptedEvent, progress → ProgressEvent. Enhances TypeScript autocompletion and validation for event callbacks; no runtime behavior changes.

Copy link

coderabbitai bot commented Aug 25, 2025

Walkthrough

Refined event type annotations in packages/runtime-dom/src/jsx.ts's exported Events interface: eight handlers had their event parameter types updated to more specific DOM event types. No runtime logic or other interfaces were modified. (≤50 words)

Changes

Cohort / File(s) Summary
JSX event type refinements
packages/runtime-dom/src/jsx.ts
Updated Events interface typings: onBeforeinputInputEvent, onSubmitSubmitEvent, onAuxclickPointerEvent, onClickPointerEvent, onContextmenuPointerEvent, onAbortUIEvent, onEncryptedMediaEncryptedEvent, onProgressProgressEvent. No other changes.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Form event typing updates: onBeforeinput → InputEvent and onSubmit → SubmitEvent (#13796)
Mouse event typing to PointerEvent (onAuxclick/onClick/onContextmenu) (#13796)
Media event typing: onAbort → UIEvent and onProgress → ProgressEvent (#13796)
Image/media extra typings (onError → ErrorEvent, onEncrypted → MediaEncryptedEvent) (#13796) onEncrypted is updated in the diff; onError change is not present in the provided diff so status for onError is unclear.

Poem

I hop through types with careful paws,
nudging events to finer laws.
Input, pointer, progress, and play—
tidier typings light the way.
A rabbit nods: code hooray! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4da2ede and 4ba78d5.

📒 Files selected for processing (1)
  • packages/runtime-dom/src/jsx.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-dom/src/jsx.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0f916d8 and 729e112.

📒 Files selected for processing (1)
  • packages/runtime-dom/src/jsx.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
🔇 Additional comments (3)
packages/runtime-dom/src/jsx.ts (3)

1333-1333: onEncrypted → MediaEncryptedEvent is correct for HTMLMediaElement.

Accurately models Encrypted Media Extensions; good improvement.

Similar to SubmitEvent, MediaEncryptedEvent’s availability depends on the consumer’s lib.dom version. If Vue’s supported TS range already guarantees it, we’re good; otherwise consider documenting the minimum TS/lib.dom version in the release notes for this change.


1341-1341: onProgress → ProgressEvent is correct.

Matches media/XHR progress semantics and exposes loaded/total, etc.


1299-1303: Confirmed TypeScript ≥4.4 (root ~5.6.2) supports InputEvent & SubmitEvent

  • The root package.json pins TypeScript to “~5.6.2”, which is well above the 4.4 threshold when SubmitEvent was introduced to lib.dom (stackoverflow.com).
  • InputEvent has been a standard part of lib.dom for several TS releases and is included in TS 5.6.2 as well.

All form/input event typings (InputEvent for onBeforeinput/onInput, SubmitEvent for onSubmit) are safe to use.

Copy link

pkg-pr-new bot commented Aug 25, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@13804

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@13804

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@13804

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@13804

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@13804

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@13804

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@13804

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@13804

@vue/shared

npm i https://pkg.pr.new/@vue/shared@13804

vue

npm i https://pkg.pr.new/vue@13804

@vue/compat

npm i https://pkg.pr.new/@vue/compat@13804

commit: 4ba78d5

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38.4 kB 34.6 kB
vue.global.prod.js 159 kB 58.5 kB 52.1 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.5 kB 18.2 kB 16.7 kB
createApp 54.5 kB 21.2 kB 19.4 kB
createSSRApp 58.7 kB 22.9 kB 20.9 kB
defineCustomElement 59.5 kB 22.8 kB 20.8 kB
overall 68.5 kB 26.4 kB 24.1 kB

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@edison1105
Copy link
Member

@cszhjh Thanks for the PR. I think we can refer to the following type definition.

// /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts
interface GlobalEventHandlersEventMap {
    "abort": UIEvent;
    "animationcancel": AnimationEvent;
    "animationend": AnimationEvent;
    "animationiteration": AnimationEvent;
    "animationstart": AnimationEvent;
    "auxclick": PointerEvent;
    "beforeinput": InputEvent;
    "beforematch": Event;
    "beforetoggle": ToggleEvent;
    "blur": FocusEvent;
    "cancel": Event;
    "canplay": Event;
    "canplaythrough": Event;
    "change": Event;
    "click": PointerEvent;
    "close": Event;
    "compositionend": CompositionEvent;
    "compositionstart": CompositionEvent;
    "compositionupdate": CompositionEvent;
    "contextlost": Event;
    "contextmenu": PointerEvent;
    "contextrestored": Event;
    "copy": ClipboardEvent;
    "cuechange": Event;
    "cut": ClipboardEvent;
    "dblclick": MouseEvent;
    "drag": DragEvent;
    "dragend": DragEvent;
    "dragenter": DragEvent;
    "dragleave": DragEvent;
    "dragover": DragEvent;
    "dragstart": DragEvent;
    "drop": DragEvent;
    "durationchange": Event;
    "emptied": Event;
    "ended": Event;
    "error": ErrorEvent;
    "focus": FocusEvent;
    "focusin": FocusEvent;
    "focusout": FocusEvent;
    "formdata": FormDataEvent;
    "gotpointercapture": PointerEvent;
    "input": Event;
    "invalid": Event;
    "keydown": KeyboardEvent;
    "keypress": KeyboardEvent;
    "keyup": KeyboardEvent;
    "load": Event;
    "loadeddata": Event;
    "loadedmetadata": Event;
    "loadstart": Event;
    "lostpointercapture": PointerEvent;
    "mousedown": MouseEvent;
    "mouseenter": MouseEvent;
    "mouseleave": MouseEvent;
    "mousemove": MouseEvent;
    "mouseout": MouseEvent;
    "mouseover": MouseEvent;
    "mouseup": MouseEvent;
    "paste": ClipboardEvent;
    "pause": Event;
    "play": Event;
    "playing": Event;
    "pointercancel": PointerEvent;
    "pointerdown": PointerEvent;
    "pointerenter": PointerEvent;
    "pointerleave": PointerEvent;
    "pointermove": PointerEvent;
    "pointerout": PointerEvent;
    "pointerover": PointerEvent;
    "pointerrawupdate": Event;
    "pointerup": PointerEvent;
    "progress": ProgressEvent;
    "ratechange": Event;
    "reset": Event;
    "resize": UIEvent;
    "scroll": Event;
    "scrollend": Event;
    "securitypolicyviolation": SecurityPolicyViolationEvent;
    "seeked": Event;
    "seeking": Event;
    "select": Event;
    "selectionchange": Event;
    "selectstart": Event;
    "slotchange": Event;
    "stalled": Event;
    "submit": SubmitEvent;
    "suspend": Event;
    "timeupdate": Event;
    "toggle": ToggleEvent;
    "touchcancel": TouchEvent;
    "touchend": TouchEvent;
    "touchmove": TouchEvent;
    "touchstart": TouchEvent;
    "transitioncancel": TransitionEvent;
    "transitionend": TransitionEvent;
    "transitionrun": TransitionEvent;
    "transitionstart": TransitionEvent;
    "volumechange": Event;
    "waiting": Event;
    "webkitanimationend": Event;
    "webkitanimationiteration": Event;
    "webkitanimationstart": Event;
    "webkittransitionend": Event;
    "wheel": WheelEvent;
}

@cszhjh
Copy link
Contributor Author

cszhjh commented Aug 25, 2025

@edison1105 Thank you for your guidance, it has been really helpful to me. I truly appreciate it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/runtime-dom/src/jsx.ts (1)

1307-1307: onError should be Event for element-level handlers (not ErrorEvent)

For element attributes like , , etc., GlobalEventHandlersEventMap specifies Event. ErrorEvent is for Window/Worker “error”. Keep this as Event to avoid misleading fields (e.g., filename, lineno).

Apply this diff:

-  onError: ErrorEvent
+  onError: Event
🧹 Nitpick comments (3)
packages/runtime-dom/src/jsx.ts (3)

1315-1317: Prefer deriving click-family types from lib.dom instead of hard-coding PointerEvent

Using GlobalEventHandlersEventMap avoids drift across TS versions and documents intent clearly. It still resolves to PointerEvent in current lib.dom while remaining future-proof.

Suggested diff:

-  onAuxclick: PointerEvent
-  onClick: PointerEvent
-  onContextmenu: PointerEvent
+  onAuxclick: GlobalEventHandlersEventMap['auxclick']
+  onClick: GlobalEventHandlersEventMap['click']
+  onContextmenu: GlobalEventHandlersEventMap['contextmenu']

Verification:

  • Ensure CI’s TypeScript lib.dom maps these to PointerEvent (as referenced in the discussion).
  • Spot-check that handlers typed as (e: MouseEvent) => void continue to be accepted (bivariance should preserve compatibility, but worth a quick dts test).

1328-1328: Derive abort type from GlobalEventHandlersEventMap for consistency

UIEvent matches current lib.dom for abort on elements, but referencing the map keeps us aligned if upstream changes.

Suggested diff:

-  onAbort: UIEvent
+  onAbort: GlobalEventHandlersEventMap['abort']

1341-1341: Good narrowing: onProgress as ProgressEvent; consider deriving from lib.dom

Typing to ProgressEvent is correct. For consistency with the approach above, you may want to pull from GlobalEventHandlersEventMap.

Suggested diff:

-  onProgress: ProgressEvent
+  onProgress: GlobalEventHandlersEventMap['progress']
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6d3d08c and 4da2ede.

📒 Files selected for processing (1)
  • packages/runtime-dom/src/jsx.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
🔇 Additional comments (3)
packages/runtime-dom/src/jsx.ts (3)

1299-1299: Good change: onBeforeinput now typed as InputEvent

Aligns with lib.dom and prevents over-generic Event usage. No concerns.


1302-1302: Good change: onSubmit now typed as SubmitEvent

Matches GlobalEventHandlersEventMap and modern browser typings.


1333-1333: Looks correct: “encrypted” as MediaEncryptedEvent

This aligns with HTMLMediaElement event typing. Please confirm our supported TS versions include MediaEncryptedEvent in lib.dom (typical in modern TS). If older TS versions are supported, consider a minimal dts test to guard.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@edison1105
Copy link
Member

/ecosystem-ci run

@edison1105 edison1105 added ready to merge The PR is ready to be merged. and removed wait changes labels Aug 25, 2025
@vue-bot
Copy link
Contributor

vue-bot commented Aug 25, 2025

📝 Ran ecosystem CI: Open

suite result latest scheduled
primevue success success
vant failure success
language-tools success success
pinia success success
quasar success success
nuxt success success
vue-i18n success success
radix-vue success success
vueuse success success
vitepress success success
vue-macros failure failure
router success success
vuetify success success
vue-simple-compiler success success
vite-plugin-vue success success
test-utils success success

@edison1105 edison1105 merged commit 24fccb4 into vuejs:main Aug 25, 2025
14 checks passed
@jimmylab
Copy link

I found two more event type mismatch according to MDN input event submit event
Type of "input" is "Event" even in interface GlobalEventHandlersEventMap(lib.dom.d.ts).

interface Event {
  // ...
  onInput: InputEvent;
  onSubmit: SubmitEvent;
  // ...
}

BTW, I came across with a workaround by modifying type EventHandlers, need more test:

interface Event {
  // ...
  onInput: Event | InputEvent;
  onBeforeinput: Event | InputEvent;
  // ...
}
type EventHandlers<E> = {
  [K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : DistributedEventHandler<E[K]>;
};
type DistributedEventHandler<TEvent> = TEvent extends any ? (payload: TEvent) => void : never;

so that both flavor of event handlers are supported, maximize the compatibility:

<template>
  <input @input="legacy" @beforeinput="brandNew" />
<template>
<script setup lang="ts">
function legacy(ev: Event) { }
function brandNew(ev: InputEvent) { }
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged. scope: types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better event argument types
4 participants