-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
TypeScript 5 support for sourceMap option #26203
Comments
I found this old issue that throws the same error. Maybe that helps |
Hi, I encountered the same error with typescript@5, and |
Encountering the same issue with Typescript 5.0.3 - solution was just to pin our cypress tests to 4.9.5 while aforementioned GH issues get resolved. |
Yep please give us a few, there are some TS 5 incompatibilities - some of them are upstream, in |
The issue is we hard code inlineSourceMap:
One work around would be to provide your own preprocessor and webpack config that does not set this option, eg: https://github.com/elevatebart/cypress-with-ts5/compare/main...lmiller1990:cypress-with-ts5:example-fix?expand=1 Alternatively, you should be able to modify our defaults and remove the I don’t know if we can just remove the |
Facing the same error |
@lmiller1990 in export default defineConfig({
...
e2e: {
setupNodeEvents(on) {
const options = { ...webpackPreprocessor.defaultOptions };
console.log(JSON.stringify(options));
},
},
}) However, the rule you mention does not appear in the result. {"webpackOptions":{"mode":"development","module":{"rules":[{"test":{},"exclude":[{}],"use":[{"loader":"babel-loader","options":{"presets":["@babel/preset-env"]}}]}]}},"watchOptions":{}} Strangely, I can't find
Sadly this fails for me too as I'm having trouble finding the right webpack.config to use and the cypress compilation returns an import error for my own module. I've tried |
@flavianh does ^ work for you? Re:
Yeah - it's part of the actual Cypress app, which has it's own When you tried making your own webpack config, you got an error - what is that? Maybe we can work through it. |
Also wanted to to upgrade typescript to a 5.x.x version, but the Cypress typescript compilation failed, because of cypress-io/cypress#26203
BREAKING CHANGE: Angular 16 required This closes cloudnc#298 Also wanted to to upgrade typescript to a 5.x.x version, but the Cypress typescript compilation failed, because of cypress-io/cypress#26203
BREAKING CHANGE: Angular 16 required This closes cloudnc#298 Also wanted to to upgrade typescript to a 5.x.x version, but the Cypress typescript compilation failed, because of cypress-io/cypress#26203
BREAKING CHANGE: Angular 16 required This closes cloudnc#298 Also wanted to to upgrade typescript to a 5.x.x version, but the Cypress typescript compilation failed, because of cypress-io/cypress#26203
I have successfully used the workaround above (for now - I remain hopeful that the workaround is only temporarily necessary). I already had a What I don't understand though is why this error only appears after upgrading to TypeScript 5.x? I have always had So with TypeScript 4.x, this was fine: /* tsconfig.json */
{
"compilerOptions": {
// ...
"sourceMap": true,
// ...
}
}
/* cypress/tsconfig.json */
{
"extends": "../tsconfig.json",
"compilerOptions": {
// Nothing here about source maps
}
} But with TypeScript 5.x we need this: /* tsconfig.json */
{
"compilerOptions": {
// ...
"sourceMap": true, // same as always
// ...
}
}
/* cypress/tsconfig.json */
{
"extends": "../tsconfig.json",
"compilerOptions": {
// ...
"sourceMap": false // <-- workaround
// ...
}
} Not that it really matters, but I would be curious to know what actually changed with TypeScript 5.x that triggered the need for the workaround? |
@scottohara TypeScript 5.x did make changes related to tsconfig.json: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#supporting-multiple-configuration-files-in-extends |
Yeah, that was my first thought too, but that change seems to relate to extending from multiple configs. I suppose it is possible that in making those changes they have somehow altered how certain config values in a single base |
face the same issue and would like to remove the workaround again |
I've tried the workaround at #26203 (comment) but my problem is that If I set sourceMap to false in the tsconfig.json of the workspace, it works fine.
|
This feels painfully similar to #8477 🥲 |
Any updates on this? |
The provided workaround won't work if you attempt to import files from outside the Cypress directory. Whether this is a good or bad idea is a separate discussion, but it can pose real issues for many projects. In such cases, the main tsconfig.json will be picked up. Are there any plans to address this issue on the Cypress side? |
…dir [PT-186622946] Cypress has a bug that breaks tests that import files imported from outside the Cypress folder when TypeScript 5+ is used: cypress-io/cypress#26203 These tests were currently skipped anyway, so moving them out of the basic dir so Cypress doesn't even try to run them and fail because of the sourceMap issue. Hopefully, this Cypress bug gets fixed before we will have time to re-enable these tests.
Having the same issue, setting "sourceMap: false" does not work as a workaround. |
1 similar comment
Having the same issue, setting "sourceMap: false" does not work as a workaround. |
@peniqliotuv can you point me to any resources on how to run cypress with an older version of typescript? |
You can use the ' resolutions' field in the package file |
@peniqliotuv Can you be more specific? Sorry I'm relatively new to this kind of thing. Much appreciated |
Permit me to ask a potentially silly question. If I understand correctly, this issue arises when:
... conflicts with
... as these two tsconfig options ( The workaround that many of us here have successfully used to avoid this error is to explicitly set Given the mutual exclusivity of these two config options and the fact that Cypress hardcodes the value of one of the options; shouldn't it also hardcode the value of the other? That is, instead of asking every end-user that encounters this error to apply the same workaround, would it be possible for Cypress to force webpackOptions.module.rules.push({
test: /\.tsx?$/,
exclude: [/node_modules/],
use: [
{
loader: require.resolve('ts-loader'),
options: {
compiler: options.typescript,
compilerOptions: {
inlineSourceMap: true, // if this is true...
inlineSources: true,
downlevelIteration: true,
+ sourceMap: false, // ...then this MUST be false
},
logLevel: 'error',
silent: true,
transpileOnly: true,
},
},
],
}) Or would that not fix the issue because anything in the user-supplied |
Hi, After upgrading Typescript to version As @scottohara said, that shouldn't (in theory) be that complicated as we can evaluate both Anyways, the workaround is applied and hopefully we can move forward until we have nailed-down solution. |
This is still broken for me with Cypress version 13.11.0. I have the sourceMap: false in cypress/tsconfig.json, but it looks like as others have said in this thread, this file is not being picked up. My folder structure that leads to the Cypress tsconfig.json file is as follows: My node_modules are located here: So it looks like it should be the correct location to me.. |
@CedricHg the fix for this should make its way into the next release of Cypress, which is targeted for around June 18th, 2024 |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
If I want to use TypeScript 5 and use sourceMap in my tsconfig.json, cypress errors with the following error.
Desired behavior
No response
Test code to reproduce
https://github.com/elevatebart/cypress-with-ts5/
Cypress Version
12.8.1
Node version
v18.7.0
Operating System
macOS 13.2.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: