mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 20:03:37 +08:00
DEV: Improve JSDoc for withPluginApi (#29758)
This allows consumers to get intellisense completions on the `api.` argument of their callback
This commit is contained in:
parent
fd1220af69
commit
f70cc6215c
|
@ -3362,7 +3362,6 @@ class PluginApi {
|
|||
registeredTabs.push(tab);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
#deprecatedWidgetOverride(widgetName, override) {
|
||||
// insert here the code to handle widget deprecations, e.g. for the header widgets we used:
|
||||
// if (DEPRECATED_HEADER_WIDGETS.includes(widgetName)) {
|
||||
|
@ -3436,11 +3435,12 @@ function getPluginApi(version) {
|
|||
}
|
||||
|
||||
/**
|
||||
* withPluginApi(version, apiCodeCallback, opts)
|
||||
* Executes the provided callback function with the `PluginApi` object if the specified API version is available.
|
||||
*
|
||||
* Helper to version our client side plugin API. Pass the version of the API that your
|
||||
* plugin is coded against. If that API is available, the `apiCodeCallback` function will
|
||||
* be called with the `PluginApi` object.
|
||||
* @param {number} version - The version of the API that the plugin is coded against.
|
||||
* @param {(api: PluginApi, opts: object) => void} apiCodeCallback - The callback function to execute if the API version is available
|
||||
* @param {object} [opts] - Optional additional options to pass to the callback function.
|
||||
* @returns {*} The result of the `callback` function, if executed
|
||||
*/
|
||||
export function withPluginApi(version, apiCodeCallback, opts) {
|
||||
opts = opts || {};
|
||||
|
|
Loading…
Reference in New Issue
Block a user