From e9c9d187b978d060771d514fe58e580585ebe9dc 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 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 d424be535cac00..9bbf75ce745b60 100644 --- a/lib/internal/modules/esm/hooks.js +++ b/lib/internal/modules/esm/hooks.js @@ -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, diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index f3902075049bff..0651f775eeafe0 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 */ @@ -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} 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);