Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typings: fix JSDoc in ESM loader modules #48424

Merged
merged 1 commit into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/internal/modules/esm/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
});


/**
* @typedef {object} ExportedHooks
* @property {Function} globalPreload Global preload hook.
* @property {Function} resolve Resolve hook.
* @property {Function} load Load hook.
*/

/**
* @typedef {object} KeyedHook
* @property {Function} fn The hook function.
Expand Down Expand Up @@ -631,7 +638,7 @@ ObjectSetPrototypeOf(HooksProxy.prototype, null);
/**
* A utility function to pluck the hooks from a user-defined loader.
* @param {import('./loader.js).ModuleExports} exports
* @returns {import('./loader.js).ExportedHooks}
* @returns {ExportedHooks}
*/
function pluckHooks({
globalPreload,
Expand Down
22 changes: 2 additions & 20 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,10 @@ function getTranslators() {
*/
let hooksProxy;

/**
* @typedef {object} ExportedHooks
* @property {Function} globalPreload Global preload hook.
* @property {Function} resolve Resolve hook.
* @property {Function} load Load hook.
*/

/**
* @typedef {Record<string, any>} ModuleExports
*/

/**
* @typedef {object} KeyedExports
* @property {ModuleExports} exports The contents of the module.
* @property {URL['href']} url The URL of the module.
*/

/**
* @typedef {'builtin'|'commonjs'|'json'|'module'|'wasm'} ModuleFormat
*/
Expand Down Expand Up @@ -229,17 +216,12 @@ class DefaultModuleLoader {

/**
* This method is usually called indirectly as part of the loading processes.
* Internally, it is used directly to add loaders. Use directly with caution.
*
* This method must NOT be renamed: it functions as a dynamic import on a
* loader module.
* Use directly with caution.
* @param {string} specifier The first parameter of an `import()` expression.
* @param {string} parentURL Path of the parent importing the module.
* @param {Record<string, string>} importAssertions Validations for the
* module import.
* @returns {Promise<ExportedHooks | KeyedExports[]>}
* A collection of module export(s) or a list of collections of module
* export(s).
* @returns {Promise<ModuleExports>}
*/
async import(specifier, parentURL, importAssertions) {
const moduleJob = this.getModuleJob(specifier, parentURL, importAssertions);
Expand Down