mapper icon indicating copy to clipboard operation
mapper copied to clipboard

Doesn't work with Typescript 4.9 or newer with moduleResolution:"node16"

Open iamchathu opened this issue 2 years ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the issue

The imports doesn't work with latest Typescript versions with moduleResolution:"node16"

I did instigate on this and used

npx @arethetypeswrong/cli --from-npm @automapper/[email protected]

It does following output

👺 Import resolved to an ESM type declaration file, but a CommonJS JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md

🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the JavaScript files. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md


┌───────────────────┬──────────────────────────────┐
│                   │ "@automapper/core"           │
├───────────────────┼──────────────────────────────┤
│ node10            │ 🟢                           │
├───────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ 👺 Masquerading as ESM       │
│                   │ 🥴 Internal resolution error │
├───────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 🥴 Internal resolution error │
├───────────────────┼──────────────────────────────┤
│ bundler           │ 🟢                           │
└───────────────────┴──────────────────────────────┘

Seems both CJS and ESM are broken for node16 resolution mode.

Models/DTOs/VMs

No response

Mapping configuration

No response

Steps to reproduce

No response

Expected behavior

Should work with new Typescript version with ES Module resolution.

Screenshots

No response

Minimum reproduction code

No response

Package

  • [ ] I don't know.
  • [X] @automapper/core
  • [X] @automapper/classes
  • [ ] @automapper/nestjs
  • [ ] @automapper/pojos
  • [ ] @automapper/mikro
  • [ ] @automapper/sequelize
  • [ ] Other (see below)

Other package and its version

No response

AutoMapper version

8.0.0

Additional context

No response

iamchathu avatar Nov 04 '23 13:11 iamchathu

Any plans to tackle this @nartc? or did you figure it out @iamchathu

driley-abbvie avatar Jan 10 '24 20:01 driley-abbvie

@driley-abbvie Nope. I tried patching the module but seems have to do lot of work to get done manually. Better to setup something like tsup to generate seperate type definitions for both module types

iamchathu avatar Feb 11 '24 21:02 iamchathu

Even the latest version has the same issue.

npx @arethetypeswrong/cli --from-npm @automapper/[email protected]
┌───────────────────┬──────────────────────────────┐
│                   │ "@automapper/core"           │
├───────────────────┼──────────────────────────────┤
│ node10            │ 🟢                           │
├───────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ 👺 Masquerading as ESM       │
│                   │ 🥴 Internal resolution error │
├───────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 👺 Masquerading as ESM       │
│                   │ 🥴 Internal resolution error │
├───────────────────┼──────────────────────────────┤
│ bundler           │ 🟢                           │
└───────────────────┴──────────────────────────────┘

iamchathu avatar Feb 11 '24 21:02 iamchathu