Minor improvements to typings
Created by: aj-r
There are a few issues in index.d.ts
that go against Typescript's best practices:
- Never use the
Object
type. We should useobject
instead, or better yet, define a proper interface for those objects. - Never use the
Function
type. Instead, define a more specific signature for that function.- e.g. instead of
listener: Function
, we should do something likelistener: (e: any) => void
. Although hopefully we can replaceany
with a more specific event interface. - We might want to write different overloads for
MediaPlayerClass.on
for each different type of event object. For example:... on(type: 'allTextTracksAdded', listener: (e: AllTextTracksAddedEvent) => void, scope?: object); on(type: 'textTrackAdded', listener: (e: TextTrackAddedEvent) => void, scope?: object); on(type: 'canPlay', listener: () => void, scope?: object); ...
- e.g. instead of
- It would also be nice to add JSDoc comments into
index.d.ts
so they show up in IDEs like Visual Studio Code. Ideally we could automate this, but for now it might be easiest to copy/paste them?
I can make a PR for this, since I assume it's not a high priority for most people. I can fill out the feedback agreement, but how do I send it to the mailing list? I'm not too familiar with how google groups works.