three-stdlib icon indicating copy to clipboard operation
three-stdlib copied to clipboard

Fix event dispatcher types

Open RodrigoHamuy opened this issue 11 months ago • 2 comments

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 https://github.com/three-types/three-ts-types/pull/1398 instead.

RodrigoHamuy avatar Dec 12 '24 14:12 RodrigoHamuy

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.

codesandbox-ci[bot] avatar Dec 12 '24 14:12 codesandbox-ci[bot]

This could work, but not a fan!!

RodrigoHamuy avatar Dec 12 '24 14:12 RodrigoHamuy