Closed s-rigaud closed 2 weeks ago
Good question! Those may have been left in by mistake in https://github.com/three-types/three-ts-types/pull/369. I'm experimenting with removing them in https://github.com/three-types/three-ts-types/pull/1145, but it does seem to break some tests, so I need to look into that some more.
~I was able to fix all the tests fairly easily, and they seemed like positive changes. 🎉 Let's give this a go!~
Blocked by an error in another package's tests, will need to fix that first.
The
EventDispatcher
only has one method definition fordispatchEvent
which is strict.https://github.com/three-types/three-ts-types/blob/c8cea806df55a23ff020819be3abb86c27a4adfe/types/three/src/core/EventDispatcher.d.ts#L84
While there are multiple method definitions for
addEventListener
which make the typing a bit loose.https://github.com/three-types/three-ts-types/blob/c8cea806df55a23ff020819be3abb86c27a4adfe/types/three/src/core/EventDispatcher.d.ts#L52-L55
https://github.com/three-types/three-ts-types/blob/c8cea806df55a23ff020819be3abb86c27a4adfe/types/three/src/core/EventDispatcher.d.ts#L56
I don't understand why
addEventListener
is loose when it directly depends overdispatchEvent
which is strict. Shouldn't the loosest implementation based over regular string be removed ? It would raise error when listening to none defined event and thus be more type safe 🤔 It will be especially useful when creating custom controls inheriting fromEventDispatcher
.