From 81f640eb6af435d980495fd479000f9b21a82897 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 12 Oct 2023 00:23:20 -0700 Subject: [PATCH] =?UTF-8?q?[@types/node]=20Update=20the=20definition=20of?= =?UTF-8?q?=20`import.meta.resolve(=E2=80=A6)`=20for=20`node`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was previously available: - behind a flag, - returning a `Promise`, and - with an optional second `parent` parameter. As of `node` v20.6.0 (https://nodejs.org/en/blog/release/v20.6.0), it is now: - unflagged (with a single param), - synchronous, and - with the `parent` parameter only being supported behind the `--experimental-import-meta-resolve` flag. To minimize the potential of confusion that would come from mixing the unflagged version with flagged parameter, this change only documents the unflagged version. This also matches the API implemented by all browsers, avoiding the potential misunderstandings about the second parameter in codebased with mixed frontend and backend code. Note that there was a bug that sometimes returned a `URL` instead of a `string` in v20.6.0, but this was fixed in v20.8.0 (https://github.com/nodejs/node/issues/49695). --- types/node/module.d.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/types/node/module.d.ts b/types/node/module.d.ts index d83aec94aae2df9..2f2259694274904 100644 --- a/types/node/module.d.ts +++ b/types/node/module.d.ts @@ -92,18 +92,12 @@ declare module 'module' { interface ImportMeta { url: string; /** - * @experimental - * This feature is only available with the `--experimental-import-meta-resolve` - * command flag enabled. - * * Provides a module-relative resolution function scoped to each module, returning * the URL string. * - * @param specified The module specifier to resolve relative to `parent`. - * @param parent The absolute parent module URL to resolve from. If none - * is specified, the value of `import.meta.url` is used as the default. + * @param specifier The module specifier to resolve relative to the current module's URL (`import.meta.url`). */ - resolve?(specified: string, parent?: string | URL): Promise; + resolve(specifier: string): string; } } export = Module;