refactor(events): type the dispatched event (drop the any bag)#72
Merged
bigmistqke merged 1 commit intoJun 7, 2026
Merged
Conversation
The event Pointer dispatches was built by createThreeEvent then grown by mutation across move/dispatch/click/propagate as `event: any` (7 casts): currentObject/currentIntersection set per node, capture methods bolted on, plugin extra Object.assign'd. Introduce a DispatchEvent<TExtra> view — the writable shape the Pointer assembles (optional event fields + Partial<PointerCapture> + typed extra). createThreeEvent returns it and merges a typed `extra`; dispatch is generic over TExtra. The dispatch path is now fully typed (no `any` on the event), and a plugin source's extra fields (e.g. the XR controller payload) are type-checked instead of merged blind. Handlers still receive the precise public ThreeEvent via their prop types; runtime behavior is unchanged.
commit: |
bigmistqke
added a commit
to bigmistqke/solid-three
that referenced
this pull request
Jun 7, 2026
Now that core dispatch is generic over the event's extra fields (solidjs-community#72), declare the controller's extra once as XRControllerExtra and reuse it for both the dispatch call (dispatch<XRControllerExtra>) and the handler type (XRThreeEvent = ThreeEvent<XRInputSourceEvent> & XRControllerExtra) — so the payload the source supplies and the type handlers receive can no longer drift, and the merge is type-checked instead of blind.
Open
2 tasks
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.
An architecture-review deepening: the event
Pointerdispatches to handlers had almost no type depth —createThreeEventreturned a bag, thenmove/dispatch/click/propagatere-typed itany(7 casts) and grew it by mutation (currentObject/currentIntersectionper node, capture methods bolted on, pluginextraObject.assign'd).Change
DispatchEvent<TExtra>— the writable shape thePointerassembles (optional event fields +Partial<PointerCapture>+ typedextra).createThreeEventreturns it and merges a typedextra;dispatch<TExtra>is generic.anyon the event — and a plugin source's extra fields (e.g. the XR controller payload) are type-checked instead of merged blind. Handlers still receive the precise publicThreeEventvia their prop types.Notes
extracontract.dispatch<XRControllerExtra>soXRThreeEventbecomes derived, not hand-merged — that integration lands when feat(xr)!: XR as a plugin — solid-three/xr (xrEvents + controller capture + createXR/useXR) #65 rebases on top of this.Test plan
pnpm lint+pnpm buildgreen.createThreeEventtyping test).