Comments (11)
It looks like jsdoc is ok with using @param {function():void} fn
? The API docs output defines it as a function, and the type definition becomes ready(fn: () => void, sync?: boolean): void;
. Seems simpler than defining ReadyCallback
.
from video.js.
The ready method comes from Component, which Player inherits from. ready
on a component, would have the this
be that Component, which, in the case of Player, would be the player.
We don't override the method in player.js, but maybe we can use jsdoc to update the method signature there?
from video.js.
I'm not sure, maybe overriding the type signature is possible. This is not that important if it's difficult to fix as users can cast the usage in the function so it's kind-of OK. The other problem with the return type is breaking all usages of ready
though.
from video.js.
yeah, these two lines should be removed. Not sure why they were re-added the last time that piece was touched:
Lines 841 to 842 in 8729e31
from video.js.
I guess that is wrong, yes, because I don't see the code returning anything from ready
. But will that fix the other issue that the fn
argument is marked as returning Component
? I don't understand how this maps to the fn
parameter? I see fn
defined as a ReadyCallback
above this but I don't find a definition for ReadyCallback
anywhere in the codebase.
from video.js.
ReadyCallback
is here, but I don't know why that is interpreted as it would return a Component
Lines 28 to 34 in 8729e31
from video.js.
Looking in VSCode, when I hover over ReadyCallback
, the tooltip says type ReadyCallback = /*unresolved*/ any
. I'm not sure how this @callback
annotation works. But maybe because TS can't resolve ReadyCallback
it thinks that the line below (which says @return {Component}
) also applies to it? But on the other hand I see that fn
is defined with this: Component
so it did somehow read the definition of ReadyCallback
... I'm not sure, all these jsdoc annotations are really strange. π
from video.js.
It's all very complicated because typescript understands a subset of jsdoc when generating the types, and also some typescript-specific syntax in jsdoc but which jsdoc itself doesn't understand, and breaks generating the API docs. Finding a balance that works for both is hard.
If I remove the @return
from ready()
and add @return {undefined}
in Component.js, then component.d.ts has this:
ready(fn: () => undefined, sync?: boolean): void;
from video.js.
This also doesn't work, the return type must be void
. Doesn't @return {void}
work? Or simply removing @return
?
from video.js.
{function():void}
seems to work by accident rather than design, and would break jsdoc if it were any more complicated, e.g. documenting arguments. So not a good precedent to set. Going back to defined callbacks, I have this, which specifies this
for the Player's callback but leaves Component's unspecified. Returning {void}
isn't really right in jsdoc itself as js functions that don't explicitly return do return undefined
. But it's probably well understood. Any thoughts?
from video.js.
I'm really not the person to review JSDoc. π But as for the undefined
- of course JavaScript itself doesn't have a concept of void
but TypeScript does - and that's absolutely the right way to specify this function as it indeed does not return a value (even though there is an implicit return at runtime).
from video.js.
Related Issues (20)
- HLS + Fairplay streams buffers a lot in Mac Safari browser. HOT 3
- Volume slider not accessible using TalkBack HOT 1
- Poor Video Streaming Support - How to Improve??? HOT 3
- Why player.volume(val) fires volumechange event? HOT 3
- DRM | Safari | Fair Play License is not being called HOT 2
- The player does not support m3u8 videos in H265 format HOT 2
- [8.14.1] Duplicate HTML IDs
- It works for adding other custom headers but not working for overwriting the 'User-Agent' request header. Can you please refer to some information about it. HOT 9
- Mouseover tooltip on progress bar is not in sync with cursor when Zoom is used in css HOT 1
- More duplicate HTML IDs
- AudioTrackKind misalignment re description(s) HOT 4
- 18188346394291764?s_bl=1&s_fbp=iev1-1&s_prp=hel3-1&s_sw=0&s_tids=1&s_vt=ig&a=AbyzeDsRHihJINSg HOT 1
- How to reload vtt subtitles tracks?
- DURATION ISSUE BUG HOT 1
- VideoJS player not working on Opera, FireFox and Safari HOT 1
- Still facing issue with progress bar not completing 100% HOT 1
- Uncaught SyntaxError: Unexpected token ( and Uncaught ReferenceError: videojs is not defined in chrome v 53 HOT 1
- Error Playing m3u8 videoοΌ1. VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) video append of 96872b failed for segment #0 in playlist 3 οΌ2. VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported. HOT 3
- Automatically select HLS when available HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from video.js.