Skip to content
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

refactor(types): Type enhancements #8968

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

mister-ben
Copy link
Contributor

@mister-ben mister-ben commented Jan 23, 2025

Several changes for Typescript.

  • Adds a jsdoc plugin to not break on @template {xyz} T. Replaces uses of T with Class.<xyz>
    • Used in component.js
  • Adds definitions for ComponentOptions, SourceObject, PlayerOptions, MediaObject
  • Removes further uses of ~ namespacing, which is valid jsdoc, but which tsc fails to understand
  • Changes track kinds to simple union types. Change the existing definitions to enums so we can use them as object lookups without conflicting with the standard definitions.
  • Use native TextTrackCue, TextTrackKind definitions.
  • Exports Player, PlayerOptions and Plugin from video.js.
    • This makes it easier to add to the object than at present e.g. in a plugin to declare module 'video.js' { interface Player {
    • This sets a precedent - what else could/should be exported at this level? Should the names be more verbose?
  • Adds additional jsdoc on for track and readyState in HTMLTrackElement, as tsc doesn't understand documentation for properties added with Object.defineProperties . Fixes HTMLTrackElement class provided missing two properties as stated in MDN #8959

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.31%. Comparing base (c7298d4) to head (88aead4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8968      +/-   ##
==========================================
- Coverage   84.88%   84.31%   -0.58%     
==========================================
  Files         120      120              
  Lines        8152     8154       +2     
  Branches     1964     1964              
==========================================
- Hits         6920     6875      -45     
- Misses       1232     1279      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -617,3 +620,7 @@ videojs.url = Url;
videojs.Error = VjsErrors;

export default videojs;
export {
Player,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows adding to the Player interface in plugins:

declare module 'video.js' {
  interface Player {
    touchOverlay: TouchOverlay;
    touchOverlayDirect: TouchOverlay;
    mobileUi: {
      (options?: MobileUiPluginOptions): void;
      VERSION: string;
    }
  }
}

* The key/value store of options that will get passed to children of
* the child.
*
* @param {number} [index=this.children_.length]
* The index to attempt to add a child into.
*
*
* @return {Component}
* @return {T}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renders like this in the API docs with the changes to jsdoc-typeof-plugin:
image

@mister-ben mister-ben changed the title [WIP] Type enhancements refactor(types): Type enhancements Feb 15, 2025
@mister-ben mister-ben marked this pull request as ready for review February 15, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTMLTrackElement class provided missing two properties as stated in MDN
2 participants