Skip to content

error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls #756

@dilame

Description

@dilame

Version

5.26.2

Describe the bug

I just made initial setup of typesafe-i18n, trying to build my project now and stumbled into 3 TS errors

node_modules/typesafe-i18n/runtime/esm/runtime/src/index.d.ts:1:15 - error TS1479: 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("../../../../types/runtime/src/index.mjs")' call instead.

1 export * from '../../../../types/runtime/src/index.mjs'
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/typesafe-i18n/detectors/index.d.ts:1:15 - error TS1479: 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("../types/detectors/src/index.mjs")' call instead.

1 export * from '../types/detectors/src/index.mjs'
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/typesafe-i18n/utils/index.d.ts:1:15 - error TS1479: 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("../types/utils/src/index.mjs")' call instead.

1 export * from '../types/utils/src/index.mjs'

Reproduction

{
  "extends": "./tsconfig.checks.json",
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "esModuleInterop": true,
    "target": "ESNext",
    "lib": ["ESNext", "DOM"],
    "types": ["node", "jest"],
    "removeComments": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "useDefineForClassFields": false,
    "sourceMap": true,
    "resolveJsonModule": true,
    "baseUrl": "./",
  }
}

Logs

No response

Config

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions