From a74d9512d536f5ac2610f79cef7f7dd823b7431b Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 5 Mar 2024 14:11:51 +0100 Subject: [PATCH] Fix ESM type import in Webpack loader CJS file TypeScript 5.3 introduced support for import attributes and `resolution-mode`. This can be used to import types from ESM files into CJS files without a `@ts-ignore` comment. --- packages/loader/index.cjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/loader/index.cjs b/packages/loader/index.cjs index eab55a2da..f70efe021 100644 --- a/packages/loader/index.cjs +++ b/packages/loader/index.cjs @@ -1,10 +1,8 @@ /** * @typedef {import('webpack').LoaderContext} LoaderContext + * @typedef {import('./lib/index.js', {with: {'resolution-mode': 'import'}}).Options} Options */ -// @ts-expect-error: TS complains about CJS importing ESM but it works. -/** @typedef {import('./lib/index.js').Options} Options */ - 'use strict' // Note: we can’t export immediately, as TS generates broken types.