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

Fix event dispatcher types #392

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RodrigoHamuy
Copy link
Contributor

@RodrigoHamuy RodrigoHamuy commented Dec 12, 2024

Why

As part of fixing #387, we did #388.

But it resulted in useThree().set({controls: ...}) not working with three-stdlib as their controls don't match the types.

This loosens the types a bit more so useThree().set({controls}) can work again with three-stdlib controls.

What

This PR loosen up the three-stdlib copy of EventDispatcher to fix that.

But it requires some updates to drei types to work there.

Checklist

  • Ready to be merged

DREI

This will require also updating DREI here:

- export type OrbitControlsChangeEvent = Event & {
-   target: EventTarget & { object: Camera }
- }
+ type ExtractCallback<T, E extends string> = T extends { addEventListener(event: E, callback: infer C): void } ? C : never;
+ export type OrbitControlsChangeEvent = Parameters<ExtractCallback<OrbitControlsImpl, 'change'>>[0]

Alternative solution

We revert #388 and merge three-types/three-ts-types#1398 instead.

Copy link

codesandbox-ci bot commented Dec 12, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@RodrigoHamuy
Copy link
Contributor Author

This could work, but not a fan!!

@RodrigoHamuy RodrigoHamuy reopened this Dec 12, 2024
@RodrigoHamuy RodrigoHamuy changed the title Fix/event distpatcher types Fix event dispatcher types Dec 13, 2024
@RodrigoHamuy RodrigoHamuy marked this pull request as ready for review December 18, 2024 14:33
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.

1 participant