1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-25 02:42:10 +02:00

fix: Improves types for registerPlugin and getPlugin (#8058)

* fix: improves types for registerPlugin and getPlugin

* fix: corrects parameter type for registerPlugin

* docs(fix): add support for {typeof class} expression

* chore: move js-doc-typeof-plugin to build dir
This commit is contained in:
Grzegorz Blaszczyk 2023-01-24 22:07:30 +01:00 committed by GitHub
parent 509b3d0757
commit 2e96253632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -33,7 +33,7 @@
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css"
]
},
"plugins": ["plugins/markdown"],
"plugins": ["plugins/markdown", "build/jsdoc-typeof-plugin"],
"markdown": {
"tags": ["example"],
"idInHeadings": true

View File

@ -0,0 +1,12 @@
/**
* The jsdoc plugin that will convert types like {typeof ClassName} into {Class<ClassName>}
*/
exports.handlers = {
jsdocCommentFound: event => {
event.comment = (event.comment || '').replace(/\{.*typeof\s+([^\s\|]+).*\}/g, typeExpression => {
return typeExpression.replace(/typeof\s+([^\s\|\}]+)/g, (expression, className) => {
return 'Class<' + className + '>';
});
});
}
};

View File

@ -52,7 +52,7 @@ const pluginExists = (name) => pluginStorage.hasOwnProperty(name);
* @param {string} name
* The name of a plugin.
*
* @return {Function|undefined}
* @return {typeof Plugin|Function|undefined}
* The plugin (or undefined).
*/
const getPlugin = (name) => pluginExists(name) ? pluginStorage[name] : undefined;
@ -336,10 +336,10 @@ class Plugin {
* must not match an existing plugin or a method on the `Player`
* prototype.
*
* @param {Function} plugin
* @param {typeof Plugin|Function} plugin
* A sub-class of `Plugin` or a function for basic plugins.
*
* @return {Function}
* @return {typeof Plugin|Function}
* For advanced plugins, a factory function for that plugin. For
* basic plugins, a wrapper function that initializes the plugin.
*/
@ -444,7 +444,7 @@ class Plugin {
* @param {string} name
* The name of a plugin.
*
* @returns {Function|undefined}
* @returns {typeof Plugin|Function|undefined}
* The plugin (or `undefined`).
*/
Plugin.getPlugin = getPlugin;