Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove loosely-typed event listener methods #1145

Merged
merged 7 commits into from
Aug 30, 2024

Conversation

Methuselah96
Copy link
Contributor

@Methuselah96 Methuselah96 commented Aug 12, 2024

Fixes #1143

@Methuselah96 Methuselah96 changed the title Remove loose event listeners Remove loosely-typed event listener methods Aug 12, 2024
@Methuselah96 Methuselah96 marked this pull request as ready for review August 12, 2024 22:57
@Methuselah96
Copy link
Contributor Author

Waiting on DefinitelyTyped/DefinitelyTyped#70279

@s-rigaud
Copy link
Contributor

s-rigaud commented Aug 13, 2024

In one of my projects, I ended up with a signature like this for a custom TransformControls, might be great to be added here I think:

type ChangedEvents = {
  [K in `${string}-changed`]: any
}
type EventMap = THREE.Object3DEventMap & ChangedEvents & {
  change: unknown
  objectChange: unknown
  mouseDown: { mode: string }
  mouseUp: { mode: string }
}

class CustomTransformControls extends Object3D<EventMap> {

The special changed case is here to handle this special dispatch case

https://github.com/mrdoob/three.js/blob/4f067f0f4dc9e81f7fb3484962f2e973f71fab60/examples/jsm/controls/TransformControls.js#L89

@Methuselah96 Methuselah96 merged commit e302363 into master Aug 30, 2024
4 of 5 checks passed
@Methuselah96 Methuselah96 deleted the remove-loose-event-listeners branch August 30, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EventDispatcher typing consistency
2 participants