Skip to content

Commit f3b6766

Browse files
AtofStrykercypress-bot[bot]
and
cypress-bot[bot]
authored
fix: update cypress to Typescript 5 (#29568)
* fix: update the monorepo to typescript 5 * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * run ci to see problems [run ci] * update vue-tsc and typings that conflict with update * regen snapshot * fix typescript errors ui test as stack trace behavior has changed * fix server unit tests * update cy.origin() spec based on stack traces and code frames * update spec to include source map url * run ci * fix check-ts * chore: fix system tests [run ci] * add preprocessor tests to batteries included to exercise new logic * run ci * refactor unit tests to be a bit more dry * pin typescript to ~5.4 and adjust config to ignroe deprecations but keep importsNotUsedAsValues * add changelog entry * add fixme issue to stack trace mismatches inside evaled context * use import type webpack as webpack as a lib isn't actually invboked in the runner webpack config * fix system test as adding 4 lines of comments impacts the stack trace line 4 lines (duh) --------- Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
1 parent 09c6876 commit f3b6766

File tree

62 files changed

+599
-566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+599
-566
lines changed

cli/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ _Released 6/4/2024_
1616

1717
- Fixed a situation where the Launchpad would hang if the project config had not been loaded when the Launchpad first queries the current project. Fixes [#29486](https://github.com/cypress-io/cypress/issues/29486).
1818
- Pre-emptively fix behavior with Chrome for when `unload` events are forcefully deprecated by using `pagehide` as a proxy. Fixes [#29241](https://github.com/cypress-io/cypress/issues/29241).
19+
- Fixed an issue where `inlineSourceMaps` was still being used when `sourceMaps` was provided in a users typescript config for typescript version 5. Fixes [#26203](https://github.com/cypress-io/cypress/issues/26203).
20+
21+
**Dependency Updates:**
22+
23+
- Updated typescript from `4.7.4` to `5.3.3`. Addressed in [#29568](https://github.com/cypress-io/cypress/pull/29568).
1924

2025
**Misc:**
2126

npm/angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@angular/core": "^14.2.0",
1717
"@angular/platform-browser-dynamic": "^14.2.0",
1818
"@cypress/mount-utils": "0.0.0-development",
19-
"typescript": "^4.7.4",
19+
"typescript": "~5.4.5",
2020
"zone.js": "~0.11.4"
2121
},
2222
"peerDependencies": {

npm/cypress-schematic/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@types/node": "^18.17.5",
2626
"chai": "4.2.0",
2727
"mocha": "3.5.3",
28-
"typescript": "^4.7.4"
28+
"typescript": "^5.4.5"
2929
},
3030
"peerDependencies": {
3131
"@angular/cli": ">=14",

npm/grep/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"description": "Filter tests using substring",
55
"main": "src/support.js",
66
"scripts": {
7-
"cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'",
87
"cy:open": "node ../../scripts/cypress.js open --e2e -b electron --config specPattern='**/unit.js'",
8+
"cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'",
99
"lint": "eslint . --ext .js,.ts"
1010
},
1111
"dependencies": {
@@ -16,7 +16,7 @@
1616
"devDependencies": {
1717
"cypress-each": "^1.11.0",
1818
"cypress-expect": "^2.5.3",
19-
"typescript": "^4.7.4"
19+
"typescript": "^5.4.5"
2020
},
2121
"peerDependencies": {
2222
"cypress": ">=10"

npm/mount-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"rollup": "3.7.3",
1818
"rollup-plugin-dts": "5.0.0",
1919
"rollup-plugin-typescript2": "^0.29.0",
20-
"typescript": "^4.7.4"
20+
"typescript": "^5.4.5"
2121
},
2222
"files": [
2323
"dist"

npm/puppeteer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"sinon": "^13.0.1",
3232
"sinon-chai": "^3.7.0",
3333
"ts-node": "^10.9.2",
34-
"typescript": "4.7.4"
34+
"typescript": "5.4.5"
3535
},
3636
"peerDependencies": {
3737
"cypress": ">=13.6.0"

npm/react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"react-router": "6.0.0-alpha.1",
2828
"react-router-dom": "6.0.0-alpha.1",
2929
"semver": "^7.5.3",
30-
"typescript": "^4.7.4",
30+
"typescript": "~5.4.5",
3131
"vite": "4.5.2",
3232
"vite-plugin-require-transform": "1.0.12"
3333
},

npm/react18/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"react-dom": "^16",
2323
"rollup": "3.7.3",
2424
"rollup-plugin-typescript2": "^0.29.0",
25-
"typescript": "^4.7.4"
25+
"typescript": "^5.4.5"
2626
},
2727
"peerDependencies": {
2828
"@types/react": "^18",

npm/svelte/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"devDependencies": {
1414
"@cypress/mount-utils": "0.0.0-development",
1515
"svelte": "^3.49.0",
16-
"typescript": "^4.7.4"
16+
"typescript": "^5.4.5"
1717
},
1818
"peerDependencies": {
1919
"cypress": ">=10.6.0",

npm/vite-dev-server/tsconfig.json

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
"esModuleInterop": true,
4848
/** Allows us to strip internal types sourced from webpack */
4949
"stripInternal": true,
50+
"ignoreDeprecations": "5.0",
51+
/*
52+
* TODO: remove importsNotUsedAsValues after typescript 5.5 and up as it will no longer work. If we want the same behavior
53+
* as importsNotUsedAsValues, we need to use "verbatimModuleSyntax", which will require this package to be an ES Module.
54+
*/
5055
"importsNotUsedAsValues": "error",
5156
/* skips checking declaration types. we skip this because we have multiple versions of vite installed as dev dependencies */
5257
"skipLibCheck": true,

npm/vue/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
"debug": "^4.3.4",
2525
"globby": "^11.0.1",
2626
"tailwindcss": "1.1.4",
27-
"typescript": "^4.7.4",
27+
"typescript": "~5.4.5",
2828
"vite": "4.5.2",
2929
"vue": "3.2.47",
3030
"vue-i18n": "9.0.0-rc.6",
3131
"vue-router": "^4.0.0",
32-
"vue-tsc": "^0.3.0",
32+
"vue-tsc": "^2.0.19",
3333
"vuex": "^4.0.0"
3434
},
3535
"peerDependencies": {

npm/vue2/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@rollup/plugin-replace": "^2.3.1",
1919
"@vue/test-utils": "^1.3.1",
2020
"tslib": "^2.1.0",
21-
"typescript": "^4.7.4",
21+
"typescript": "~5.4.5",
2222
"vue": "2.7.16"
2323
},
2424
"peerDependencies": {

npm/webpack-batteries-included-preprocessor/index.js

+40-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
const path = require('path')
2+
const fs = require('fs-extra')
3+
const JSON5 = require('json5')
24
const webpack = require('webpack')
5+
const Debug = require('debug')
36
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
47

8+
const debug = Debug('cypress:webpack-batteries-included-preprocessor')
9+
510
const hasTsLoader = (rules) => {
611
return rules.some((rule) => {
712
if (!rule.use || !Array.isArray(rule.use)) return false
@@ -12,6 +17,38 @@ const hasTsLoader = (rules) => {
1217
})
1318
}
1419

20+
const getTSCompilerOptionsForUser = (configFilePath) => {
21+
const compilerOptions = {
22+
sourceMap: false,
23+
inlineSourceMap: true,
24+
inlineSources: true,
25+
downlevelIteration: true,
26+
}
27+
28+
if (!configFilePath) {
29+
return compilerOptions
30+
}
31+
32+
try {
33+
// If possible, try to read the user's tsconfig.json and see if sourceMap is configured
34+
// eslint-disable-next-line no-restricted-syntax
35+
const tsconfigJSON = fs.readFileSync(configFilePath, 'utf8')
36+
// file might have trailing commas, new lines, etc. JSON5 can parse those correctly
37+
const parsedJSON = JSON5.parse(tsconfigJSON)
38+
39+
// if the user has sourceMap's configured, set the option to true and turn off inlineSourceMaps
40+
if (parsedJSON?.compilerOptions?.sourceMap) {
41+
compilerOptions.sourceMap = true
42+
compilerOptions.inlineSourceMap = false
43+
compilerOptions.inlineSources = false
44+
}
45+
} catch (e) {
46+
debug(`error in getTSCompilerOptionsForUser. Returning default...`, e)
47+
} finally {
48+
return compilerOptions
49+
}
50+
}
51+
1552
const addTypeScriptConfig = (file, options) => {
1653
// shortcut if we know we've already added typescript support
1754
if (options.__typescriptSupportAdded) return options
@@ -30,6 +67,8 @@ const addTypeScriptConfig = (file, options) => {
3067
// package using require('tsconfig'), so we alias it as 'tsconfig-aliased-for-wbip'
3168
const configFile = require('tsconfig-aliased-for-wbip').findSync(path.dirname(file.filePath))
3269

70+
const compilerOptions = getTSCompilerOptionsForUser(configFile)
71+
3372
webpackOptions.module.rules.push({
3473
test: /\.tsx?$/,
3574
exclude: [/node_modules/],
@@ -38,11 +77,7 @@ const addTypeScriptConfig = (file, options) => {
3877
loader: require.resolve('ts-loader'),
3978
options: {
4079
compiler: options.typescript,
41-
compilerOptions: {
42-
inlineSourceMap: true,
43-
inlineSources: true,
44-
downlevelIteration: true,
45-
},
80+
compilerOptions,
4681
logLevel: 'error',
4782
silent: true,
4883
transpileOnly: true,

npm/webpack-batteries-included-preprocessor/package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
"coffeescript": "2.6.0",
2525
"constants-browserify": "^1.0.0",
2626
"crypto-browserify": "^3.12.0",
27+
"debug": "^4.3.4",
2728
"domain-browser": "^4.22.0",
2829
"events": "^3.3.0",
30+
"fs-extra": "^9.1.0",
2931
"https-browserify": "^1.0.0",
32+
"json5": "2.2.3",
3033
"os-browserify": "^0.3.0",
3134
"path-browserify": "^1.0.1",
3235
"pnp-webpack-plugin": "^1.7.0",
@@ -50,10 +53,12 @@
5053
"@types/mocha": "^8.0.2",
5154
"@types/webpack": "^5.28.1",
5255
"chai": "^4.2.0",
53-
"fs-extra": "^9.1.0",
56+
"decache": "^4.6.2",
5457
"mocha": "^8.1.1",
58+
"mock-require": "3.0.3",
5559
"react": "^16.13.1",
56-
"typescript": "^4.7.4"
60+
"sinon": "18.0.0",
61+
"typescript": "^5.4.5"
5762
},
5863
"peerDependencies": {
5964
"@cypress/webpack-preprocessor": "^5.4.4"

0 commit comments

Comments
 (0)