New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve typings #2322
Improve typings #2322
Conversation
@@ -2,13 +2,14 @@ export = dashjs; | |||
export as namespace dashjs; | |||
|
|||
declare namespace dashjs { | |||
class Debug { | |||
interface Debug { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically Debug
is an interface, not a class. This is because Debug
objects are created with object literals ({}
), not with a constructor (new Debug()
).
index.d.ts
Outdated
@@ -20,16 +21,16 @@ declare namespace dashjs { | |||
} | |||
|
|||
export interface MediaInfo { | |||
id: number | null; | |||
id: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure id
should be a string, not a number. Can someone confirm?
Good work @aj-r. Regarding typings, there is still space for improvement (some properties still declared as any, full lack of types for metrics, etc) but this is going in the good direction. Thanks for the change. |
Fixes #2317.
type: string
to more specific types (e.g.type: 'video' | 'audio'
). This way typescript can catch typos, e.g.mediaPlayer.getTracksFor('vidoe')
will cause a compile error.on()
. This way listeners automatically get the right event type. e.g.