Skip to content

@import JSDoc tag doesn't seem to account for resolution-mode import attribute in TS v5.5.2Β #58955

Closed
@acidoxee

Description

@acidoxee

πŸ”Ž 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

⏯ Playground Link

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

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions