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

TS error: Option 'sourceMap' cannot be specified with option 'inlineSourceMap' #8477

Closed
IlCallo opened this issue Sep 2, 2020 · 16 comments · Fixed by #9312
Closed

TS error: Option 'sourceMap' cannot be specified with option 'inlineSourceMap' #8477

IlCallo opened this issue Sep 2, 2020 · 16 comments · Fixed by #9312
Labels
topic: typescript type: regression A bug that didn't appear until a specific Cy version release v5.0.0 🐛 Issue present since 5.0.0

Comments

@IlCallo
Copy link
Contributor

IlCallo commented Sep 2, 2020

Current behavior:

After update to Cypress 5.1, tests breaks throwing TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
If I set inlineSourceMap to false, the error persist.
If I set sourceMap to false, test start working again.

Given that the default for inlineSourceMap is false, that I do not set it, and that it breaks only on newer versions, I'd say the new webpack preprocessor forces the inlineSourceMap option to true somewhere.

This is strange because it seems like you have a whole file in place to manage this scenario: https://github.com/cypress-io/cypress-webpack-preprocessor/blob/master/lib/typescript-overrides.ts

Desired behavior:

Tests should keep working without problems

Test code to reproduce

Using a tsconfig with sourceMap: true option do the trick.


Edited to add repro:
https://github.com/IlCallo/cypress-test-tiny/tree/ts-sourcemap-conflict

  • clone locally
  • yarn install
  • yarn cypress:open
  • click on "spec.ts" test
  • witness the error

Versions

Cypress: 5.1.0
OS: Ubuntu 18.04

@bahmutov
Copy link
Contributor

bahmutov commented Sep 2, 2020

Could you please prepare a repository that we can run with a reproducible example?

@IlCallo
Copy link
Contributor Author

IlCallo commented Sep 8, 2020

@bahmutov
Here it is: https://github.com/IlCallo/cypress-test-tiny/tree/ts-sourcemap-conflict

  • clone locally
  • yarn install
  • yarn cypress:open
  • click on "spec.ts" test
  • witness the error

Given the thumbs up to the original post, seems like I'm not the only one

@Rafsonic
Copy link

I have the same issue as well. Any feedback?

Cypress: 5.1.0
OS: Ubuntu 20.04

@Kocal
Copy link
Contributor

Kocal commented Sep 24, 2020

Note that is also happens with Cypress 5.0.0 but not on 4.12.1.

As a workaround until this issue is fixed, did someone know if it is possible to specify which tsconfig.json Cypress should use?
E.g. a tsconfig-cypress.json:

{
  "extends": "./tsconfig.json",
  "sourceMap": false
}

Thanks

@IlCallo
Copy link
Contributor Author

IlCallo commented Sep 25, 2020

AFAIK you can only do this via the webpack loader which takes care of checking TS files.
Example on Quasar: https://github.com/quasarframework/quasar-testing/blob/dev/packages/e2e-cypress/src/index.js

@cellog
Copy link

cellog commented Sep 25, 2020

I see this with Cypress set up in a subdirectory, it is unable to find tsconfig.json

@aelmekeev
Copy link
Contributor

We see this issue when cypress imports some code from other subproject with its own tsconfig.json. I don't want to set sourcemap to false in there so it's blocking us completely from migrating to 5.x.

@haf
Copy link

haf commented Oct 27, 2020

Place the tsconfig.json file here to override the parent folder's tsconfig.json file. https://docs.cypress.io/guides/tooling/typescript-support.html#Configure-tsconfig-json

@aelmekeev
Copy link
Contributor

Place the tsconfig.json file here to override the parent folder's tsconfig.json file. https://docs.cypress.io/guides/tooling/typescript-support.html#Configure-tsconfig-json

@haf we do have tsconfig in cypress folder with "sourceMap": false but it doesn't help.

@haf
Copy link

haf commented Oct 27, 2020

Not in your repro https://github.com/IlCallo/cypress-test-tiny/tree/ts-sourcemap-conflict/cypress

I found this by googling the same problem. Then read the docs. Then I configured it like the docs say, and it started working. https://github.com/logary/logary-js/blob/master/cypress/tsconfig.json

@jennifer-shehane jennifer-shehane added the v5.0.0 🐛 Issue present since 5.0.0 label Oct 28, 2020
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 28, 2020

I can recreate the issue with the repo provided. Introduced in 5.0.0.

Repro

spec.ts

it('works', () => {})

tsconfig at project root

{
  "compilerOptions": {
    "sourceMap": true
  }
}

package.json

{
  "devDependencies": {
    "cypress": "^5.5.0",
    "typescript": "^4.0.2"
  }
}

Screen Shot 2020-10-28 at 12 47 11 PM

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Oct 28, 2020
@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Oct 28, 2020
@IlCallo
Copy link
Contributor Author

IlCallo commented Oct 28, 2020

@haf that's a minimal repro, my use case have the tsconfig as suggested by the docs, but that wasn't needed to show the broken behaviour

@unbugx
Copy link

unbugx commented Nov 18, 2020

Look at https://www.cypress.io/blog/2019/05/13/code-create-react-app-v3-and-its-cypress-tests-using-typescript/ It helped me a lot and everything works ok

My current cypress/tsconfig.json

{
  "extends": "../tsconfig.json",
  "include": [
    "../node_modules/cypress",
    "**/*spec.ts"
  ],
  "compilerOptions": {
    "noEmit": false,
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress"]
  }
}

@guiedugt
Copy link

Thanks @unbugx! Your answer helped me to fix the issue. I had to disable sourceMap as well, though

{
  "extends": "../../tsconfig.json",
  "include": [
    "../../node_modules/cypress",
    "**/*.ts"
  ],
  "compilerOptions": {
    "noEmit": false,
    "sourceMap": false,
    "types": ["cypress"]
  },
}

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 30, 2020

The code for this is done in cypress-io/cypress#9312, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Nov 30, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 30, 2020

Released in 6.0.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.0.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: typescript type: regression A bug that didn't appear until a specific Cy version release v5.0.0 🐛 Issue present since 5.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.