TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
Event type for readystatechange is not specific enough
Fixes https://github.com/microsoft/TypeScript/issues/41775
I was a little bit unsure whether its best to use ProgressEvent<Document>
vs making Event
generic (Event<T extends EventTarget = EventTarget>
) and then using Event<Document>
.
This is a bit of a cherrypicking of all the unspecific typed events (even if you only look at document
).
even document.onreadystatechange
is not changed... 8-/
ref #899 and https://github.com/Microsoft/TypeScript/issues/299
@HolgerJeromin Thank you for these pointers!
I actually would be in favor of turning the Event
type into something like Event<T extends EventTarget = EventTarget>
.
That shouldn't really break existing code except altering some error messages.
But this would be a larger change, so without someone from the TypeScript team chiming in and telling us they are looking for something like that, I'm somewhat hesitant to implement it. At least as part of this pr.
Looking at all the past issues with trying to make these types more explicit, we're very wary of changes here which adds generics to types which are re-used all of the place. I know it's not a perfect representation of the underlaying DOM as it is, but we're making perf vs memory vs accuracy trade-offs and I think we'll probably not take this.
@orta makes sense :) should we then close the original issue, so that we don't spend more time on this in the future?