Skip to content

typescript with esm does not work with certain tsconfig.json valuesΒ #28696

@AtofStryker

Description

@AtofStryker

Slack thread

Current behavior

Cypress is unable to run typescript/esm projects when certain values are set in the tsconfig.json. This tsconfig.json does not work with ESM when setting type: "module" in the package.json.

{
    "compilerOptions": {
      "target": "es5",
      "lib": ["dom", "dom.iterable", "esnext"],
      "allowJs": true,
      "skipLibCheck": true,
      "strict": true,
      "forceConsistentCasingInFileNames": true,
      "noEmit": true,
      "esModuleInterop": true,
      "module": "es6",
      "moduleResolution": "node",
      "resolveJsonModule": true,
      "isolatedModules": true,
      "jsx": "preserve",
      "incremental": true,
      "plugins": [{ "name": "next" }],
      "paths": { "@/*": ["./*"] }
    },
    "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
    "exclude": ["node_modules"]
  }

To workaround this issue, either comment out allowJs or bump the target to ES6 or greater

Desired behavior

Cypress should be able to run ESM with typescript regardless of the values in my tsconfig.json

Test code to reproduce

https://github.com/AtofStryker/module_reprod_ts

Cypress Version

13.6.2

Node version

v18.15.0

Operating System

macOS 13.5.1 intel

Debug Logs

Useful for debugging:


DEBUG=cypress:lifecycle:ProjectConfigIpc,cypress:server:register-ts-node,cypress:config:addToCypressConfig,cypress:lifecycle:child:run_require_async_child*,cypress:config:addToCypressConfigPlugin npx cypress open


### Other

_No response_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions