three-stdlib
three-stdlib copied to clipboard
Fix event dispatcher types
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.
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.
This could work, but not a fan!!