mirror of
https://github.com/videojs/video.js.git
synced 2024-11-24 08:42:25 +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:
parent
509b3d0757
commit
2e96253632
@ -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
|
||||
|
12
build/jsdoc-typeof-plugin.js
Normal file
12
build/jsdoc-typeof-plugin.js
Normal 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 + '>';
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user