Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use TypeScript 5.2.2 with Cypress #27946

Open
Furmanus opened this issue Sep 30, 2023 · 5 comments
Open

Unable to use TypeScript 5.2.2 with Cypress #27946

Furmanus opened this issue Sep 30, 2023 · 5 comments

Comments

@Furmanus
Copy link

Furmanus commented Sep 30, 2023

Current behavior

When trying to run cypress (v. 13.3.0) after upgrading TypeScript to 5.2.2 I'm getting following error:

> cypress run --browser chrome --headless


DevTools listening on ws://127.0.0.1:55721/devtools/browser/14f8fba2-9991-4a01-97ae-aab68abe63ce
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
Your configFile is invalid: <path_to_repo_here>/cypress.config.ts

It threw an error when required, check the stack trace below:

TSError: ⨯ Unable to compile TypeScript:
error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'.

    at createTSError (/Users/<user>/Library/Caches/Cypress/13.3.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:311:16)
    at reportTSError (/Users/<user>/Library/Caches/Cypress/13.3.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/dist/index.js:314:23)
(...rest of stack here)

Despite the fact that in my tsconfig.json both module and moduleResolution are set to NodeNext. See SO thread: https://stackoverflow.com/questions/77202439/typescript-5-2-2-with-cypress-js . After downgrading TypeScript to 5.1.6. Cypress is working fine. My project compiles and runs on TS 5.2.2 otherwise (except for cypress tests).

Desired behavior

Cypress tests should run normally.

Test code to reproduce

tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "removeComments": true,
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "target": "esnext",
    "jsx": "react",
    "noEmitOnError": true,
    "allowSyntheticDefaultImports": true,
    "isolatedModules": true,
    "incremental": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "downlevelIteration": true,
    "resolveJsonModule": true
  },
  "include": [
    "./src/scripts/**/*"
  ]
}

cypress.config.ts contents:

import { defineConfig } from 'cypress';

export default defineConfig({
    e2e: {
        baseUrl: 'http://localhost:5020',
        specPattern: 'cypress/e2e/**/*.e2e-spec.ts',
    },
});

Cypress Version

13.3.0

Node version

18.16.1

Operating System

macOS 13.4

Debug Logs

No response

Other

No response

@abieler-sap
Copy link

Actually it is not possible to use sourceMap with TypeScript 5.x. Try setting sourcMap to false in your tsconfig.json.
See #26203

@koooge
Copy link
Contributor

koooge commented Oct 20, 2023

I encountered the same error with [email protected] and node16:

    "module": "node16",
    "moduleResolution": "node16",
TSError: ⨯ Unable to compile TypeScript:
error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.

The following workaround worked for me.
#26308 (comment)

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Jun 15, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2024
@zeid0ne
Copy link

zeid0ne commented Jul 16, 2024

steal having this problem with typescript 5.5.3 and cypress 13.13.0

@jennifer-shehane jennifer-shehane removed the stale no activity on this issue for a long period label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants