@import JSDoc tag doesn't seem to account for resolution-mode import attribute in TS v5.5.2 ยท Issue #58955 ยท microsoft/TypeScript (original) (raw)

๐Ÿ”Ž Search Terms

"resolution-mode"

๐Ÿ•— Version & Regression Information

I was unable to test this on prior versions because the @import tag is newly available on TS 5.5.2

No response

๐Ÿ’ป Code

// @filename: esm/esm.js export type MyType = { foo: 'bar' }

// @filename: cjs/cjs.js // This works: /** @typedef {import('../esm/esm.js', { with: { 'resolution-mode': 'import' } }).MyType} MyType */

// This doesn't: /** @import {MyType} from '../esm/esm.js' with { 'resolution-mode': 'import' } */

I couldn't create a TS playground because of this issue: #52666

๐Ÿ™ Actual behavior

The @import usage in this context yields the following error:

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../esm/esm.js")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field "type": "module" to '/cjs/package.json'. ts(1479)

๐Ÿ™‚ Expected behavior

The @import tag should account for import attributes like with { 'resolution-mode': 'import' } to enable cross CJS/ESM type imports.

Additional information about the issue

No response