Skip to content

Commit 781eb43

Browse files
fix(types): improves quality of typescript definitions (videojs#8218)
* feat(types): improves quality of typescript definitions * fix: reverts back access modifier for controlText_ * empty commit to force retest * fix(doc): add missing keyboard event type --------- Co-authored-by: mister-ben <[email protected]>
1 parent 9267c46 commit 781eb43

10 files changed

+29
-11
lines changed

src/js/big-play-button.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BigPlayButton extends Button {
3636
* This gets called when a `BigPlayButton` "clicked". See {@link ClickableComponent}
3737
* for more detailed information on what a click can be.
3838
*
39-
* @param {KeyboardEvent} event
39+
* @param {KeyboardEvent|MouseEvent|TouchEvent} event
4040
* The `keydown`, `tap`, or `click` event that caused this function to be
4141
* called.
4242
*
@@ -47,7 +47,7 @@ class BigPlayButton extends Button {
4747
const playPromise = this.player_.play();
4848

4949
// exit early if clicked via the mouse
50-
if (this.mouseused_ && event.clientX && event.clientY) {
50+
if (this.mouseused_ && 'clientX' in event && 'clientY' in event) {
5151
silencePromise(playPromise);
5252

5353
if (this.player_.tech(true)) {
@@ -74,12 +74,29 @@ class BigPlayButton extends Button {
7474
}
7575
}
7676

77+
/**
78+
* Event handler that is called when a `BigPlayButton` receives a
79+
* `keydown` event.
80+
*
81+
* @param {KeyboardEvent} event
82+
* The `keydown` event that caused this function to be called.
83+
*
84+
* @listens keydown
85+
*/
7786
handleKeyDown(event) {
7887
this.mouseused_ = false;
7988

8089
super.handleKeyDown(event);
8190
}
8291

92+
/**
93+
* Handle `mousedown` events on the `BigPlayButton`.
94+
*
95+
* @param {MouseEvent} event
96+
* `mousedown` or `touchstart` event that triggered this function
97+
*
98+
* @listens mousedown
99+
*/
83100
handleMouseDown(event) {
84101
this.mouseused_ = true;
85102
}

src/js/button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Button extends ClickableComponent {
106106
* This gets called when a `Button` has focus and `keydown` is triggered via a key
107107
* press.
108108
*
109-
* @param {Event} event
109+
* @param {KeyboardEvent} event
110110
* The event that caused this function to get called.
111111
*
112112
* @listens keydown

src/js/clickable-component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class ClickableComponent extends Component {
233233
*
234234
* By default, if the key is Space or Enter, it will trigger a `click` event.
235235
*
236-
* @param {Event} event
236+
* @param {KeyboardEvent} event
237237
* The `keydown` event that caused this function to be called.
238238
*
239239
* @listens keydown

src/js/close-button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CloseButton extends Button {
7171
*
7272
* By default, if the key is Esc, it will trigger a `click` event.
7373
*
74-
* @param {Event} event
74+
* @param {KeyboardEvent} event
7575
* The `keydown` event that caused this function to be called.
7676
*
7777
* @listens keydown

src/js/component.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ class Component {
13241324
* delegates to `handleKeyDown`. This means anyone calling `handleKeyPress`
13251325
* will not see their method calls stop working.
13261326
*
1327-
* @param {Event} event
1327+
* @param {KeyboardEvent} event
13281328
* The event that caused this function to be called.
13291329
*/
13301330
handleKeyPress(event) {
@@ -1336,7 +1336,7 @@ class Component {
13361336
* support toggling the controls through a tap on the video. They get enabled
13371337
* because every sub-component would have extra overhead otherwise.
13381338
*
1339-
* @private
1339+
* @protected
13401340
* @fires Component#tap
13411341
* @listens Component#touchstart
13421342
* @listens Component#touchmove

src/js/menu/menu-item.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class MenuItem extends ClickableComponent {
8888
* Ignore keys which are used by the menu, but pass any other ones up. See
8989
* {@link ClickableComponent#handleKeyDown} for instances where this is called.
9090
*
91-
* @param {Event} event
91+
* @param {KeyboardEvent} event
9292
* The `keydown` event that caused this function to be called.
9393
*
9494
* @listens keydown

src/js/menu/menu.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class Menu extends Component {
205205
/**
206206
* Handle a `keydown` event on this menu. This listener is added in the constructor.
207207
*
208-
* @param {Event} event
208+
* @param {KeyboardEvent} event
209209
* A `keydown` event that happened on the menu.
210210
*
211211
* @listens keydown

src/js/player.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,7 @@ class Player extends Component {
31643164
* This allows player-wide hotkeys (either as defined below, or optionally
31653165
* by an external function).
31663166
*
3167-
* @param {Event} event
3167+
* @param {KeyboardEvent} event
31683168
* The `keydown` event that caused this function to be called.
31693169
*
31703170
* @listens keydown

src/js/utils/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function _cleanUpEvents(elem, type) {
6464
* @param {Element|Object} elem
6565
* Element or object to bind listeners to
6666
*
67-
* @param {string} type
67+
* @param {string[]} types
6868
* Type of event to bind to.
6969
*
7070
* @param {Function} callback

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"include": ["src/js/**/*"],
33
"compilerOptions": {
44
"allowJs": true,
5+
"allowSyntheticDefaultImports": true,
56
"declaration": true,
67
"emitDeclarationOnly": true,
78
"outDir": "dist/types",

0 commit comments

Comments
 (0)