From f8680f962a605413c0ddeca503b847a75f2f25b0 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`=2020.6.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was previously available: - returning a `Promise`, - behind a flag, 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: - synchronous, - unflagged without a parameter, 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. 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..aa92bac7bf35dfa 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 specified The module specifier to resolve relative to the current module's URL (`import.meta.url`). */ - resolve?(specified: string, parent?: string | URL): Promise; + resolve?(specified: string): string; } } export = Module;