From 2ef80f12b962dfabcf6e1e446bae97cb2e595864 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 11 Jun 2023 21:09:21 +0200 Subject: [PATCH] typings: fix JSDoc in ESM loader modules PR-URL: https://github.com/nodejs/node/pull/48424 Backport-PR-URL: https://github.com/nodejs/node/pull/50669 Reviewed-By: Jacob Smith Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Mestery Reviewed-By: Geoffrey Booth --- lib/internal/modules/esm/hooks.js | 9 ++++++++- lib/internal/modules/esm/loader.js | 22 ++-------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/lib/internal/modules/esm/hooks.js b/lib/internal/modules/esm/hooks.js index 3a01f7ffb71014..5112ece845219d 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -62,6 +62,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. @@ -630,7 +637,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, diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index 2c48702a3816ff..9eb05c020cbe20 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -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} 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 */ @@ -239,17 +226,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} importAssertions Validations for the * module import. - * @returns {Promise} - * A collection of module export(s) or a list of collections of module - * export(s). + * @returns {Promise} */ async import(specifier, parentURL, importAssertions) { const moduleJob = this.getModuleJob(specifier, parentURL, importAssertions);