diff --git a/dev-packages/e2e-tests/test-applications/generic-ts5.0/.npmrc b/dev-packages/e2e-tests/test-applications/generic-ts5.0/.npmrc new file mode 100644 index 000000000000..070f80f05092 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/generic-ts5.0/.npmrc @@ -0,0 +1,2 @@ +@sentry:registry=http://127.0.0.1:4873 +@sentry-internal:registry=http://127.0.0.1:4873 diff --git a/dev-packages/e2e-tests/test-applications/generic-ts5.0/index.ts b/dev-packages/e2e-tests/test-applications/generic-ts5.0/index.ts new file mode 100644 index 000000000000..beb10260da38 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/generic-ts5.0/index.ts @@ -0,0 +1,5 @@ +import * as _SentryReplay from '@sentry-internal/replay'; +import * as _SentryBrowser from '@sentry/browser'; +import * as _SentryCore from '@sentry/core'; +import * as _SentryNode from '@sentry/node'; +import * as _SentryWasm from '@sentry/wasm'; diff --git a/dev-packages/e2e-tests/test-applications/generic-ts5.0/package.json b/dev-packages/e2e-tests/test-applications/generic-ts5.0/package.json new file mode 100644 index 000000000000..1079d8f4c793 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/generic-ts5.0/package.json @@ -0,0 +1,26 @@ +{ + "name": "@sentry-internal/ts5.0-test", + "private": true, + "license": "MIT", + "scripts": { + "build:types": "pnpm run type-check", + "ts-version": "tsc --version", + "type-check": "tsc --project tsconfig.json", + "test:build": "pnpm install && pnpm run build:types", + "test:assert": "pnpm -v" + }, + "devDependencies": { + "typescript": "5.0.2", + "@types/node": "^18.19.1" + }, + "dependencies": { + "@sentry/browser": "latest || *", + "@sentry/core": "latest || *", + "@sentry/node": "latest || *", + "@sentry-internal/replay": "latest || *", + "@sentry/wasm": "latest || *" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/dev-packages/e2e-tests/test-applications/generic-ts5.0/tsconfig.json b/dev-packages/e2e-tests/test-applications/generic-ts5.0/tsconfig.json new file mode 100644 index 000000000000..95de9c93fc38 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/generic-ts5.0/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["index.ts"], + "compilerOptions": { + "lib": ["es2018", "DOM"], + "skipLibCheck": false, + "noEmit": true, + "types": [], + "target": "es2018", + "moduleResolution": "node" + } +} diff --git a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/package.json b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/package.json index 503ad2758767..bf0b59ca0adf 100644 --- a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/package.json +++ b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/package.json @@ -41,6 +41,7 @@ "@total-typescript/ts-reset": "^0.4.2", "@types/eslint": "^8.4.10", "@types/react": "^18.2.22", + "@types/node": "^18.19.1", "@types/react-dom": "^18.2.7", "esbuild": "0.25.0", "eslint": "^9.18.0", diff --git a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tsconfig.json b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tsconfig.json index 0d4c4dc2e4de..6b1b95f76f6f 100644 --- a/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tsconfig.json +++ b/dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/tsconfig.json @@ -14,7 +14,7 @@ "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "baseUrl": ".", - "types": ["@shopify/oxygen-workers-types"], + "types": ["@shopify/oxygen-workers-types", "node"], "paths": { "~/*": ["app/*"] }, diff --git a/package.json b/package.json index edbd645b3c97..de0b46add91b 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "size-limit": "~11.1.6", "sucrase": "^3.35.0", "ts-node": "10.9.1", - "typescript": "~5.0.0", + "typescript": "~5.8.0", "vitest": "^3.2.4", "yalc": "^1.0.0-pre.53", "yarn-deduplicate": "6.0.2" diff --git a/packages/browser-utils/src/metrics/instrument.ts b/packages/browser-utils/src/metrics/instrument.ts index 8017bd4c89e1..4c461ec6776c 100644 --- a/packages/browser-utils/src/metrics/instrument.ts +++ b/packages/browser-utils/src/metrics/instrument.ts @@ -301,7 +301,7 @@ function instrumentPerformanceObserver(type: InstrumentHandlerTypePerformanceObs function addHandler(type: InstrumentHandlerType, handler: InstrumentHandlerCallback): void { handlers[type] = handlers[type] || []; - (handlers[type] as InstrumentHandlerCallback[]).push(handler); + handlers[type].push(handler); } // Get a callback which can be called to remove the instrumentation handler diff --git a/packages/browser/src/profiling/utils.ts b/packages/browser/src/profiling/utils.ts index 66b202c8517f..8b7039be7a9b 100644 --- a/packages/browser/src/profiling/utils.ts +++ b/packages/browser/src/profiling/utils.ts @@ -564,7 +564,8 @@ export function addProfileToGlobalCache(profile_id: string, profile: JSSelfProfi PROFILE_MAP.set(profile_id, profile); if (PROFILE_MAP.size > 30) { - const last: string = PROFILE_MAP.keys().next().value; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const last = PROFILE_MAP.keys().next().value!; PROFILE_MAP.delete(last); } } diff --git a/packages/core/src/instrument/handlers.ts b/packages/core/src/instrument/handlers.ts index 86c5a90b7c52..74dbc9902348 100644 --- a/packages/core/src/instrument/handlers.ts +++ b/packages/core/src/instrument/handlers.ts @@ -21,7 +21,7 @@ const instrumented: { [key in InstrumentHandlerType]?: boolean } = {}; /** Add a handler function. */ export function addHandler(type: InstrumentHandlerType, handler: InstrumentHandlerCallback): void { handlers[type] = handlers[type] || []; - (handlers[type] as InstrumentHandlerCallback[]).push(handler); + handlers[type].push(handler); } /** diff --git a/packages/core/src/utils/debug-ids.ts b/packages/core/src/utils/debug-ids.ts index 97f30bbe816a..fd31009ae32d 100644 --- a/packages/core/src/utils/debug-ids.ts +++ b/packages/core/src/utils/debug-ids.ts @@ -105,7 +105,7 @@ export function getDebugImagesForResources( images.push({ type: 'sourcemap', code_file: path, - debug_id: filenameDebugIdMap[path] as string, + debug_id: filenameDebugIdMap[path], }); } } diff --git a/packages/core/src/utils/lru.ts b/packages/core/src/utils/lru.ts index 2a3b7bfc8ac0..3158dff7d413 100644 --- a/packages/core/src/utils/lru.ts +++ b/packages/core/src/utils/lru.ts @@ -27,7 +27,9 @@ export class LRUMap { public set(key: K, value: V): void { if (this._cache.size >= this._maxSize) { // keys() returns an iterator in insertion order so keys().next() gives us the oldest key - this._cache.delete(this._cache.keys().next().value); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const nextKey = this._cache.keys().next().value!; + this._cache.delete(nextKey); } this._cache.set(key, value); } diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 6ba07cd09f8f..0b0506d373b0 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -331,7 +331,7 @@ export function constructWebpackConfigFunction({ .map(extension => `global-error.${extension}`) .some( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - globalErrorFile => fs.existsSync(path.join(appDirPath!, globalErrorFile)), + globalErrorFile => fs.existsSync(path.join(appDirPath, globalErrorFile)), ); if ( diff --git a/packages/nextjs/tsconfig.test.json b/packages/nextjs/tsconfig.test.json index 633c4212a0e9..be787654b1a0 100644 --- a/packages/nextjs/tsconfig.test.json +++ b/packages/nextjs/tsconfig.test.json @@ -9,6 +9,7 @@ // require for top-level await "module": "Node16", + "moduleResolution": "Node16", "target": "es2020", // other package-specific, test-specific options diff --git a/packages/node-core/src/integrations/anr/worker.ts b/packages/node-core/src/integrations/anr/worker.ts index 7c2ac91f30af..3ae9e009625c 100644 --- a/packages/node-core/src/integrations/anr/worker.ts +++ b/packages/node-core/src/integrations/anr/worker.ts @@ -110,7 +110,7 @@ function applyDebugMeta(event: Event): void { for (const frame of exception.stacktrace?.frames || []) { const filename = frame.abs_path || frame.filename; if (filename && normalisedDebugImages[filename]) { - filenameToDebugId.set(filename, normalisedDebugImages[filename] as string); + filenameToDebugId.set(filename, normalisedDebugImages[filename]); } } } diff --git a/packages/node-core/test/helpers/mockSdkInit.ts b/packages/node-core/test/helpers/mockSdkInit.ts index 0ea8a93cb064..8d4cb28bfd66 100644 --- a/packages/node-core/test/helpers/mockSdkInit.ts +++ b/packages/node-core/test/helpers/mockSdkInit.ts @@ -149,7 +149,7 @@ export function getSpanProcessor(): SentrySpanProcessor | undefined { const spanProcessor = multiSpanProcessor?.['_spanProcessors']?.find( (spanProcessor: SpanProcessor) => spanProcessor instanceof SentrySpanProcessor, - ) as SentrySpanProcessor | undefined; + ); return spanProcessor; } diff --git a/packages/node-core/tsconfig.json b/packages/node-core/tsconfig.json index 07c7602c1fdd..28abec410557 100644 --- a/packages/node-core/tsconfig.json +++ b/packages/node-core/tsconfig.json @@ -5,6 +5,7 @@ "compilerOptions": { "lib": ["ES2020", "ES2021.WeakRef"], - "module": "Node16" + "module": "Node16", + "moduleResolution": "Node16" } } diff --git a/packages/node-native/src/event-loop-block-watchdog.ts b/packages/node-native/src/event-loop-block-watchdog.ts index 26b9bb683930..492070a2d1dc 100644 --- a/packages/node-native/src/event-loop-block-watchdog.ts +++ b/packages/node-native/src/event-loop-block-watchdog.ts @@ -149,7 +149,7 @@ function applyDebugMeta(event: Event, debugImages: Record): void for (const frame of exception.stacktrace?.frames || []) { const filename = stripFileProtocol(frame.abs_path || frame.filename); if (filename && normalisedDebugImages[filename]) { - filenameToDebugId.set(filename, normalisedDebugImages[filename] as string); + filenameToDebugId.set(filename, normalisedDebugImages[filename]); } } } @@ -158,7 +158,7 @@ function applyDebugMeta(event: Event, debugImages: Record): void for (const frame of thread.stacktrace?.frames || []) { const filename = stripFileProtocol(frame.abs_path || frame.filename); if (filename && normalisedDebugImages[filename]) { - filenameToDebugId.set(filename, normalisedDebugImages[filename] as string); + filenameToDebugId.set(filename, normalisedDebugImages[filename]); } } } diff --git a/packages/node/test/helpers/mockSdkInit.ts b/packages/node/test/helpers/mockSdkInit.ts index dc4c3586d978..8f8be9e8af68 100644 --- a/packages/node/test/helpers/mockSdkInit.ts +++ b/packages/node/test/helpers/mockSdkInit.ts @@ -61,7 +61,7 @@ export function getSpanProcessor(): SentrySpanProcessor | undefined { const spanProcessor = multiSpanProcessor?.['_spanProcessors']?.find( (spanProcessor: SpanProcessor) => spanProcessor instanceof SentrySpanProcessor, - ) as SentrySpanProcessor | undefined; + ); return spanProcessor; } diff --git a/packages/node/tsconfig.json b/packages/node/tsconfig.json index 64d6f3a1b9e0..d5f034ad1048 100644 --- a/packages/node/tsconfig.json +++ b/packages/node/tsconfig.json @@ -5,6 +5,7 @@ "compilerOptions": { "lib": ["es2020"], - "module": "Node16" + "module": "Node16", + "moduleResolution": "Node16" } } diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index 1e806e4dc2eb..6d159785a5ba 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -75,14 +75,16 @@ export default defineNuxtModule({ // Add the sentry config file to the include array nuxt.hook('prepare:types', options => { - if (!options.tsConfig.include) { - options.tsConfig.include = []; + const tsConfig = options.tsConfig as { include?: string[] }; + + if (!tsConfig.include) { + tsConfig.include = []; } // Add type references for useRuntimeConfig in root files for nuxt v4 // Should be relative to `root/.nuxt` const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile); - options.tsConfig.include.push(relativePath); + tsConfig.include.push(relativePath); }); } diff --git a/packages/nuxt/src/runtime/plugins/sentry-cloudflare.server.ts b/packages/nuxt/src/runtime/plugins/sentry-cloudflare.server.ts index 5438ac829d8a..d45d45d0d4ed 100644 --- a/packages/nuxt/src/runtime/plugins/sentry-cloudflare.server.ts +++ b/packages/nuxt/src/runtime/plugins/sentry-cloudflare.server.ts @@ -1,4 +1,3 @@ -import type { IncomingRequestCfProperties } from '@cloudflare/workers-types'; import type { CloudflareOptions } from '@sentry/cloudflare'; import { setAsyncLocalStorageAsyncContextStrategy, wrapRequestHandler } from '@sentry/cloudflare'; import { debug, getDefaultIsolationScope, getIsolationScope, getTraceData } from '@sentry/core'; @@ -64,8 +63,9 @@ export const sentryCloudflareNitroPlugin = const request = new Request(url, { method: event.method, headers: event.headers, + // @ts-expect-error - 'cf' is a valid property in the RequestInit type for Cloudflare cf: getCfProperties(event), - }) as Request>; + }); const requestHandlerOptions = { options: cloudflareOptions, diff --git a/packages/remix/src/utils/utils.ts b/packages/remix/src/utils/utils.ts index 5485cff5e0a3..9cc02341ac0a 100644 --- a/packages/remix/src/utils/utils.ts +++ b/packages/remix/src/utils/utils.ts @@ -29,7 +29,7 @@ export async function storeFormDataKeys( if (formDataKeys?.[key]) { if (typeof formDataKeys[key] === 'string') { - attrKey = formDataKeys[key] as string; + attrKey = formDataKeys[key]; } span.setAttribute( diff --git a/packages/remix/src/vendor/instrumentation.ts b/packages/remix/src/vendor/instrumentation.ts index 317a17da663d..6ccc56c7a88f 100644 --- a/packages/remix/src/vendor/instrumentation.ts +++ b/packages/remix/src/vendor/instrumentation.ts @@ -310,11 +310,7 @@ export class RemixInstrumentation extends InstrumentationBase { const { actionFormDataAttributes: actionFormAttributes } = plugin.getConfig(); formData.forEach((value: unknown, key: string) => { - if ( - actionFormAttributes?.[key] && - actionFormAttributes[key] !== false && - typeof value === 'string' - ) { + if (actionFormAttributes?.[key] && typeof value === 'string') { const keyName = actionFormAttributes[key] === true ? key : actionFormAttributes[key]; span.setAttribute(`formData.${keyName}`, value.toString()); } diff --git a/packages/remix/test/integration/package.json b/packages/remix/test/integration/package.json index 04e20e5f3a56..d138a0eb8eaa 100644 --- a/packages/remix/test/integration/package.json +++ b/packages/remix/test/integration/package.json @@ -21,7 +21,7 @@ "@types/react": "^18", "@types/react-dom": "^18", "nock": "^13.5.5", - "typescript": "~5.0.0" + "typescript": "~5.8.0" }, "resolutions": { "@sentry/browser": "file:../../../browser", diff --git a/packages/remix/tsconfig.test.json b/packages/remix/tsconfig.test.json index f62d7ff34d09..dace64b4fd9a 100644 --- a/packages/remix/tsconfig.test.json +++ b/packages/remix/tsconfig.test.json @@ -8,6 +8,7 @@ "types": ["node"], // Required for top-level await in tests "module": "Node16", + "moduleResolution": "Node16", "target": "es2020", "esModuleInterop": true diff --git a/packages/sveltekit/src/worker/cloudflare.ts b/packages/sveltekit/src/worker/cloudflare.ts index 612b174f6c69..9cacad6f4cb8 100644 --- a/packages/sveltekit/src/worker/cloudflare.ts +++ b/packages/sveltekit/src/worker/cloudflare.ts @@ -39,7 +39,7 @@ export function initCloudflareSentryHandle(options: CloudflareOptions): Handle { return wrapRequestHandler( { options: opts, - request: event.request as Request>, + request: event.request, // @ts-expect-error This will exist in Cloudflare context: event.platform.context, // We don't want to capture errors here, as we want to capture them in the `sentryHandle` handler diff --git a/packages/tanstackstart-react/tsconfig.json b/packages/tanstackstart-react/tsconfig.json index ff4cadba841a..220ba3fa2b86 100644 --- a/packages/tanstackstart-react/tsconfig.json +++ b/packages/tanstackstart-react/tsconfig.json @@ -3,6 +3,7 @@ "include": ["src/**/*"], "compilerOptions": { "lib": ["es2020"], - "module": "Node16" + "module": "Node16", + "moduleResolution": "Node16" } } diff --git a/packages/tanstackstart/tsconfig.json b/packages/tanstackstart/tsconfig.json index ff4cadba841a..220ba3fa2b86 100644 --- a/packages/tanstackstart/tsconfig.json +++ b/packages/tanstackstart/tsconfig.json @@ -3,6 +3,7 @@ "include": ["src/**/*"], "compilerOptions": { "lib": ["es2020"], - "module": "Node16" + "module": "Node16", + "moduleResolution": "Node16" } } diff --git a/packages/typescript/package.json b/packages/typescript/package.json index dc465ec207dd..430842c16d09 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -13,7 +13,7 @@ "tsconfig.json" ], "peerDependencies": { - "typescript": "~5.0.0" + "typescript": "~5.8.0" }, "scripts": { "clean": "yarn rimraf sentry-internal-typescript-*.tgz", diff --git a/scripts/verify-packages-versions.js b/scripts/verify-packages-versions.js index e6f0837cb38c..81eac62e9c90 100644 --- a/scripts/verify-packages-versions.js +++ b/scripts/verify-packages-versions.js @@ -1,6 +1,6 @@ const pkg = require('../package.json'); -const TYPESCRIPT_VERSION = '~5.0.0'; +const TYPESCRIPT_VERSION = '~5.8.0'; if (pkg.devDependencies.typescript !== TYPESCRIPT_VERSION) { console.error(` diff --git a/yarn.lock b/yarn.lock index 70c9e3d80b73..3917862a705f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30045,7 +30045,7 @@ typescript@4.6.4: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== -"typescript@>=3 < 6", typescript@^5.0.4, typescript@^5.4.4, typescript@^5.7.3: +"typescript@>=3 < 6", typescript@^5.0.4, typescript@^5.4.4, typescript@^5.7.3, typescript@~5.8.0: version "5.8.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e" integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ== @@ -30060,11 +30060,6 @@ typescript@next: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.0-dev.20230530.tgz#4251ade97a9d8a86850c4d5c3c4f3e1cb2ccf52c" integrity sha512-bIoMajCZWzLB+pWwncaba/hZc6dRnw7x8T/fenOnP9gYQB/gc4xdm48AXp5SH5I/PvvSeZ/dXkUMtc8s8BiDZw== -typescript@~5.0.0: - version "5.0.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" - integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== - typeson-registry@^1.0.0-alpha.20: version "1.0.0-alpha.39" resolved "https://registry.yarnpkg.com/typeson-registry/-/typeson-registry-1.0.0-alpha.39.tgz#9e0f5aabd5eebfcffd65a796487541196f4b1211"