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

fix(types): improves quality of typescript definitions #8218

Merged
merged 6 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/js/big-play-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* This gets called when a `BigPlayButton` "clicked". See {@link ClickableComponent}
* for more detailed information on what a click can be.
*
* @param {KeyboardEvent} event
* @param {KeyboardEvent|MouseEvent|TouchEvent} event
* The `keydown`, `tap`, or `click` event that caused this function to be
* called.
*
Expand All @@ -47,7 +47,7 @@
const playPromise = this.player_.play();

// exit early if clicked via the mouse
if (this.mouseused_ && event.clientX && event.clientY) {
if (this.mouseused_ && 'clientX' in event && 'clientY' in event) {

Check warning on line 50 in src/js/big-play-button.js

View check run for this annotation

Codecov / codecov/patch

src/js/big-play-button.js#L50

Added line #L50 was not covered by tests
silencePromise(playPromise);

if (this.player_.tech(true)) {
Expand All @@ -74,12 +74,29 @@
}
}

/**
* Event handler that is called when a `BigPlayButton` receives a
* `keydown` event.
*
* @param {KeyboardEvent} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
*/
handleKeyDown(event) {
this.mouseused_ = false;

super.handleKeyDown(event);
}

/**
* Handle `mousedown` events on the `BigPlayButton`.
*
* @param {MouseEvent} event
* `mousedown` or `touchstart` event that triggered this function
*
* @listens mousedown
*/
handleMouseDown(event) {
this.mouseused_ = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Button extends ClickableComponent {
* This gets called when a `Button` has focus and `keydown` is triggered via a key
* press.
*
* @param {Event} event
* @param {KeyboardEvent} event
* The event that caused this function to get called.
*
* @listens keydown
Expand Down
2 changes: 1 addition & 1 deletion src/js/clickable-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ClickableComponent extends Component {
*
* By default, if the key is Space or Enter, it will trigger a `click` event.
*
* @param {Event} event
* @param {KeyboardEvent} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
Expand Down
2 changes: 1 addition & 1 deletion src/js/close-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CloseButton extends Button {
*
* By default, if the key is Esc, it will trigger a `click` event.
*
* @param {Event} event
* @param {KeyboardEvent} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
Expand Down
4 changes: 2 additions & 2 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ class Component {
* delegates to `handleKeyDown`. This means anyone calling `handleKeyPress`
* will not see their method calls stop working.
*
* @param {Event} event
* @param {KeyboardEvent} event
* The event that caused this function to be called.
*/
handleKeyPress(event) {
Expand All @@ -1336,7 +1336,7 @@ class Component {
* support toggling the controls through a tap on the video. They get enabled
* because every sub-component would have extra overhead otherwise.
*
* @private
* @protected
* @fires Component#tap
* @listens Component#touchstart
* @listens Component#touchmove
Expand Down
2 changes: 1 addition & 1 deletion src/js/menu/menu-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MenuItem extends ClickableComponent {
* Ignore keys which are used by the menu, but pass any other ones up. See
* {@link ClickableComponent#handleKeyDown} for instances where this is called.
*
* @param {Event} event
* @param {KeyboardEvent} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
Expand Down
2 changes: 1 addition & 1 deletion src/js/menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Menu extends Component {
/**
* Handle a `keydown` event on this menu. This listener is added in the constructor.
*
* @param {Event} event
* @param {KeyboardEvent} event
* A `keydown` event that happened on the menu.
*
* @listens keydown
Expand Down
2 changes: 1 addition & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3164,7 +3164,7 @@ class Player extends Component {
* This allows player-wide hotkeys (either as defined below, or optionally
* by an external function).
*
* @param {Event} event
* @param {KeyboardEvent} event
* The `keydown` event that caused this function to be called.
*
* @listens keydown
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function _cleanUpEvents(elem, type) {
* @param {Element|Object} elem
* Element or object to bind listeners to
*
* @param {string} type
* @param {string[]} types
* Type of event to bind to.
*
* @param {Function} callback
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"include": ["src/js/**/*"],
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "dist/types",
Expand Down