typings: fix JSDoc in ESM loader modules

PR-URL: https://github.com/nodejs/node/pull/48424
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This commit is contained in:
Antoine du Hamel
2023-06-11 21:09:21 +02:00
committed by GitHub
parent c21fe3ad87
commit d2d4a310f1
2 changed files with 10 additions and 21 deletions

View File

@@ -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.
@@ -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,

View File

@@ -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
*/
@@ -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);