From 266dbf1ae6de40755ca6247f122cd4b1819349e8 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 7 Jun 2023 09:14:25 +0200 Subject: [PATCH] build: Update typescript from 3.8.3 to 4.9.5 --- .github/workflows/build.yml | 19 +++++- nx.json | 4 +- package.json | 5 +- packages/angular-ivy/package.json | 3 +- packages/angular/package.json | 4 +- packages/angular/src/errorhandler.ts | 6 +- packages/angular/test/errorhandler.test.ts | 2 +- .../browser-integration-tests/package.json | 1 - packages/browser/package.json | 9 ++- packages/browser/src/eventbuilder.ts | 3 +- .../browser/src/integrations/breadcrumbs.ts | 2 +- .../test/unit/integrations/helpers.test.ts | 2 +- .../test/unit/transports/offline.test.ts | 2 +- packages/core/package.json | 9 ++- packages/core/src/transports/offline.ts | 4 +- packages/core/test/lib/hint.test.ts | 1 + .../core/test/lib/transports/offline.test.ts | 2 +- packages/e2e-tests/package.json | 1 - .../create-next-app/package.json | 2 +- .../create-react-app/package.json | 2 +- .../create-react-app/test-recipe.json | 7 ++ .../nextjs-app-dir/package.json | 2 +- .../package.json | 2 +- .../standard-frontend-react/package.json | 2 +- .../standard-frontend-react/test-recipe.json | 7 ++ .../test-applications/sveltekit/package.json | 2 +- packages/ember/package.json | 1 - packages/gatsby/package.json | 7 +- packages/hub/package.json | 9 ++- packages/integration-shims/package.json | 7 +- packages/integrations/package.json | 9 ++- .../integrations/test/captureconsole.test.ts | 2 +- packages/nextjs/package.json | 9 ++- .../wrapApiHandlerWithSentryVercelCrons.ts | 4 +- packages/nextjs/src/config/webpack.ts | 3 +- packages/nextjs/test/integration/package.json | 2 +- packages/nextjs/test/serverSdk.test.ts | 1 + .../node-integration-tests/utils/run-tests.ts | 2 +- packages/node/package.json | 9 ++- packages/node/test/index.test.ts | 2 +- packages/node/test/utils.test.ts | 2 +- packages/opentelemetry-node/package.json | 7 +- packages/overhead-metrics/package.json | 2 +- packages/react/package.json | 9 ++- packages/react/test/reactrouterv6.4.test.tsx | 6 ++ packages/remix/package.json | 9 ++- packages/remix/src/utils/instrumentServer.ts | 5 +- .../remix/src/utils/serverAdapters/express.ts | 2 +- packages/remix/test/integration/package.json | 2 +- packages/replay-worker/package.json | 9 ++- packages/replay-worker/src/handleMessage.ts | 2 +- packages/replay/.eslintignore | 2 + packages/replay/package.json | 9 ++- .../replay/src/coreHandlers/handleFetch.ts | 2 +- .../src/util/createPerformanceEntries.ts | 2 - .../src/util/dedupePerformanceEntries.ts | 2 - .../test/fixtures/performanceEntry/lcp.ts | 2 - .../fixtures/performanceEntry/navigation.ts | 6 +- packages/serverless/package.json | 9 ++- packages/svelte/package.json | 9 ++- packages/sveltekit/package.json | 1 - packages/tracing-internal/package.json | 9 ++- .../src/browser/metrics/index.ts | 2 + .../web-vitals/lib/getNavigationEntry.ts | 1 + .../src/node/integrations/prisma.ts | 2 +- packages/tracing/package.json | 7 +- packages/types/package.json | 7 +- packages/typescript/package.json | 2 +- packages/utils/package.json | 9 ++- packages/utils/src/envelope.ts | 2 +- packages/utils/test/envelope.test.ts | 6 +- packages/utils/test/worldwide.test.ts | 1 + packages/vue/package.json | 9 ++- packages/wasm/package.json | 9 ++- scripts/ensure-bundle-deps.ts | 2 +- scripts/verify-packages-versions.js | 2 +- yarn.lock | 68 +++++++++---------- 77 files changed, 271 insertions(+), 138 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 990361d6ae7c..daac42e560c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -654,7 +654,9 @@ jobs: yarn test:package job_node_integration_tests: - name: Node (${{ matrix.node }}) Integration Tests + name: + Node (${{ matrix.node }})${{ (matrix.typescript && format(' (TS {0})', matrix.typescript)) || '' }} Integration + Tests needs: [job_get_metadata, job_build] if: needs.job_get_metadata.outputs.changed_node == 'true' || github.event_name != 'pull_request' runs-on: ubuntu-20.04 @@ -663,6 +665,12 @@ jobs: fail-fast: false matrix: node: [10, 12, 14, 16, 18, 20] + typescript: + - false + include: + # Only check typescript for latest version (to streamline CI) + - node: 20 + typescript: '3.8' steps: - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v3 @@ -676,6 +684,11 @@ jobs: uses: ./.github/actions/restore-cache env: DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} + + - name: Overwrite typescript version + if: matrix.typescript + run: yarn add --dev --ignore-workspace-root-check typescript@${{ matrix.typescript }} + - name: Run integration tests env: NODE_VERSION: ${{ matrix.node }} @@ -714,7 +727,7 @@ jobs: yarn test:integration:ci job_e2e_tests: - name: E2E Tests (Shard ${{ matrix.shard }}) + name: E2E (Shard ${{ matrix.shard }}) Tests # We only run E2E tests for non-fork PRs because the E2E tests require secrets to work and they can't be accessed from forks # Dependabot PRs sadly also don't have access to secrets, so we skip them as well if: @@ -727,6 +740,7 @@ jobs: fail-fast: false matrix: shard: [1, 2, 3] + steps: - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v3 @@ -743,6 +757,7 @@ jobs: uses: ./.github/actions/restore-cache env: DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} + - name: Get node version id: versions run: | diff --git a/nx.json b/nx.json index 096a0b0c9620..2341174dd956 100644 --- a/nx.json +++ b/nx.json @@ -64,7 +64,9 @@ ], "outputs": [ "{projectRoot}/build/types", - "{projectRoot}/build/npm/types" + "{projectRoot}/build/types-ts3.8", + "{projectRoot}/build/npm/types", + "{projectRoot}/build/npm/types-ts3.8" ] }, "lint:eslint": { diff --git a/package.json b/package.json index 8ebd0541f657..feb5be7839d0 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "chai": "^4.1.2", "codecov": "^3.6.5", "deepmerge": "^4.2.2", + "downlevel-dts": "~0.11.0", "es-check": "7.1.0", "eslint": "7.32.0", "jest": "^27.5.1", @@ -114,9 +115,9 @@ "size-limit": "^4.5.5", "ts-jest": "^27.1.4", "ts-node": "10.9.1", - "tslib": "^2.3.1", + "tslib": "2.4.1", "typedoc": "^0.18.0", - "typescript": "3.8.3", + "typescript": "4.9.5", "vitest": "^0.29.2", "yalc": "^1.0.0-pre.53" }, diff --git a/packages/angular-ivy/package.json b/packages/angular-ivy/package.json index 736800bfdc49..e2d9110c2be1 100644 --- a/packages/angular-ivy/package.json +++ b/packages/angular-ivy/package.json @@ -24,7 +24,7 @@ "@sentry/browser": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^2.3.0" + "tslib": "^2.4.1" }, "devDependencies": { "@angular-devkit/build-angular": "~12.2.18", @@ -37,7 +37,6 @@ "@angular/platform-browser-dynamic": "~12.2.0", "@angular/router": "~12.2.0", "ng-packagr": "^12.1.1", - "typescript": "~4.3.5", "zone.js": "~0.11.4" }, "scripts": { diff --git a/packages/angular/package.json b/packages/angular/package.json index 62d840432675..de371fb700c0 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -24,7 +24,7 @@ "@sentry/browser": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^2.0.0" + "tslib": "^2.4.1" }, "devDependencies": { "@angular-devkit/build-angular": "~0.1002.4", @@ -38,7 +38,7 @@ "@angular/router": "~10.2.5", "ng-packagr": "^10.1.0", "rxjs": "6.5.5", - "typescript": "~4.0.2", + "typescript": "4.0.2", "zone.js": "^0.11.8" }, "scripts": { diff --git a/packages/angular/src/errorhandler.ts b/packages/angular/src/errorhandler.ts index 89f3b8b556ac..6940e0cc8cc1 100644 --- a/packages/angular/src/errorhandler.ts +++ b/packages/angular/src/errorhandler.ts @@ -2,7 +2,7 @@ import { HttpErrorResponse } from '@angular/common/http'; import type { ErrorHandler as AngularErrorHandler } from '@angular/core'; import { Inject, Injectable } from '@angular/core'; import * as Sentry from '@sentry/browser'; -import { captureException } from '@sentry/browser'; +import type { Event, Scope } from '@sentry/types'; import { addExceptionMechanism, isString } from '@sentry/utils'; import { runOutsideAngular } from './zone'; @@ -101,7 +101,7 @@ class SentryErrorHandler implements AngularErrorHandler { // Capture handled exception and send it to Sentry. const eventId = runOutsideAngular(() => - captureException(extractedError, scope => { + Sentry.captureException(extractedError, (scope: Scope) => { scope.addEventProcessor(event => { addExceptionMechanism(event, { type: 'angular', @@ -126,7 +126,7 @@ class SentryErrorHandler implements AngularErrorHandler { const client = Sentry.getCurrentHub().getClient(); if (client && client.on && !this._registeredAfterSendEventHandler) { - client.on('afterSendEvent', event => { + client.on('afterSendEvent', (event: Event) => { if (!event.type) { Sentry.showReportDialog({ ...this._options.dialogOptions, eventId: event.event_id }); } diff --git a/packages/angular/test/errorhandler.test.ts b/packages/angular/test/errorhandler.test.ts index c43ad41629c1..633d4d81f7e9 100644 --- a/packages/angular/test/errorhandler.test.ts +++ b/packages/angular/test/errorhandler.test.ts @@ -57,7 +57,7 @@ describe('SentryErrorHandler', () => { describe('handleError method', () => { it('handleError method assigns the correct mechanism', () => { const addEventProcessorSpy = jest.spyOn(FakeScope, 'addEventProcessor').mockImplementationOnce(callback => { - void callback({}, { event_id: 'fake-event-id' }); + void (callback as (event: any, hint: any) => void)({}, { event_id: 'fake-event-id' }); return FakeScope; }); diff --git a/packages/browser-integration-tests/package.json b/packages/browser-integration-tests/package.json index 4e467cd1ce22..dd6c0040b33c 100644 --- a/packages/browser-integration-tests/package.json +++ b/packages/browser-integration-tests/package.json @@ -53,7 +53,6 @@ "html-webpack-plugin": "^5.5.0", "pako": "^2.1.0", "playwright": "^1.31.1", - "typescript": "^4.5.2", "webpack": "^5.52.0" }, "devDependencies": { diff --git a/packages/browser/package.json b/packages/browser/package.json index b4f878d4f510..49773b2d0954 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -12,6 +12,9 @@ "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -21,7 +24,7 @@ "@sentry/replay": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "devDependencies": { "@sentry-internal/integration-shims": "7.54.0", @@ -53,7 +56,9 @@ "build:bundle:es5": "JS_VERSION=es5 rollup -c rollup.bundle.config.js", "build:bundle:es6": "JS_VERSION=es6 rollup -c rollup.bundle.config.js", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:bundle:watch": "rollup -c rollup.bundle.config.js --watch", diff --git a/packages/browser/src/eventbuilder.ts b/packages/browser/src/eventbuilder.ts index 4db58b9b7b43..83700927bc19 100644 --- a/packages/browser/src/eventbuilder.ts +++ b/packages/browser/src/eventbuilder.ts @@ -208,7 +208,7 @@ export function eventFromUnknownInput( // https://developer.mozilla.org/en-US/docs/Web/API/DOMError // https://developer.mozilla.org/en-US/docs/Web/API/DOMException // https://webidl.spec.whatwg.org/#es-DOMException-specialness - if (isDOMError(exception as DOMError) || isDOMException(exception as DOMException)) { + if (isDOMError(exception) || isDOMException(exception as DOMException)) { const domException = exception as DOMException; if ('stack' in (exception as Error)) { @@ -220,6 +220,7 @@ export function eventFromUnknownInput( addExceptionTypeValue(event, message); } if ('code' in domException) { + // eslint-disable-next-line deprecation/deprecation event.tags = { ...event.tags, 'DOMException.code': `${domException.code}` }; } diff --git a/packages/browser/src/integrations/breadcrumbs.ts b/packages/browser/src/integrations/breadcrumbs.ts index 3d019945b53b..b5f734ce939c 100644 --- a/packages/browser/src/integrations/breadcrumbs.ts +++ b/packages/browser/src/integrations/breadcrumbs.ts @@ -348,5 +348,5 @@ function _historyBreadcrumb(handlerData: HandlerData & { from: string; to: strin } function _isEvent(event: unknown): event is Event { - return event && !!(event as Record).target; + return !!event && !!(event as Record).target; } diff --git a/packages/browser/test/unit/integrations/helpers.test.ts b/packages/browser/test/unit/integrations/helpers.test.ts index a3fe734d79d4..5b06835f834d 100644 --- a/packages/browser/test/unit/integrations/helpers.test.ts +++ b/packages/browser/test/unit/integrations/helpers.test.ts @@ -157,7 +157,7 @@ describe('internal wrap()', () => { try { wrapped(); } catch (error) { - expect(error.message).toBe('boom'); + expect((error as Error).message).toBe('boom'); } }); diff --git a/packages/browser/test/unit/transports/offline.test.ts b/packages/browser/test/unit/transports/offline.test.ts index b224df725bc6..aa5819fe155a 100644 --- a/packages/browser/test/unit/transports/offline.test.ts +++ b/packages/browser/test/unit/transports/offline.test.ts @@ -47,7 +47,7 @@ export const createTestTransport = (...sendResults: MockResult( retryDelay = START_DELAY; return result; } catch (e) { - if (store && (await shouldQueue(envelope, e, retryDelay))) { + if (store && (await shouldQueue(envelope, e as Error, retryDelay))) { await store.insert(envelope); flushWithBackOff(); - log('Error sending. Event queued', e); + log('Error sending. Event queued', e as Error); return {}; } else { throw e; diff --git a/packages/core/test/lib/hint.test.ts b/packages/core/test/lib/hint.test.ts index a975174dcd78..bd795ed79c8e 100644 --- a/packages/core/test/lib/hint.test.ts +++ b/packages/core/test/lib/hint.test.ts @@ -16,6 +16,7 @@ describe('Hint', () => { afterEach(() => { jest.clearAllMocks(); + // @ts-ignore for testing delete GLOBAL_OBJ.__SENTRY__; }); diff --git a/packages/core/test/lib/transports/offline.test.ts b/packages/core/test/lib/transports/offline.test.ts index 056d11aac90a..6a6474d51ef9 100644 --- a/packages/core/test/lib/transports/offline.test.ts +++ b/packages/core/test/lib/transports/offline.test.ts @@ -98,7 +98,7 @@ const createTestTransport = ( reject(next); } else { sendCount += 1; - resolve(next as TransportMakeRequestResponse | undefined); + resolve(next as TransportMakeRequestResponse); } }); }), diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 02e45d12c952..5a1692e11183 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -26,7 +26,6 @@ "fs-extra": "11.1.0", "glob": "8.0.3", "ts-node": "10.9.1", - "typescript": "3.8.3", "yaml": "2.2.2" }, "volta": { diff --git a/packages/e2e-tests/test-applications/create-next-app/package.json b/packages/e2e-tests/test-applications/create-next-app/package.json index af2a7830f3d8..3232c1eca7fe 100644 --- a/packages/e2e-tests/test-applications/create-next-app/package.json +++ b/packages/e2e-tests/test-applications/create-next-app/package.json @@ -16,7 +16,7 @@ "next": "13.0.7", "react": "18.2.0", "react-dom": "18.2.0", - "typescript": "4.9.4" + "typescript": "4.9.5" }, "devDependencies": { "@playwright/test": "^1.27.1" diff --git a/packages/e2e-tests/test-applications/create-react-app/package.json b/packages/e2e-tests/test-applications/create-react-app/package.json index e0fc502238d0..062eef12aa45 100644 --- a/packages/e2e-tests/test-applications/create-react-app/package.json +++ b/packages/e2e-tests/test-applications/create-react-app/package.json @@ -15,7 +15,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-scripts": "5.0.1", - "typescript": "4.4.2", + "typescript": "4.9.5", "web-vitals": "2.1.0" }, "scripts": { diff --git a/packages/e2e-tests/test-applications/create-react-app/test-recipe.json b/packages/e2e-tests/test-applications/create-react-app/test-recipe.json index a45dde0d9c07..f0f5e19553cc 100644 --- a/packages/e2e-tests/test-applications/create-react-app/test-recipe.json +++ b/packages/e2e-tests/test-applications/create-react-app/test-recipe.json @@ -3,6 +3,13 @@ "testApplicationName": "create-react-app", "buildCommand": "pnpm install && pnpm build", "tests": [], + "versions": [ + { + "dependencyOverrides": { + "typescript": "3.8.3" + } + } + ], "canaryVersions": [ { "dependencyOverrides": { diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/package.json b/packages/e2e-tests/test-applications/nextjs-app-dir/package.json index b4e58ced63a2..45f79250d05f 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/package.json +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/package.json @@ -16,7 +16,7 @@ "next": "13.2.4", "react": "18.2.0", "react-dom": "18.2.0", - "typescript": "4.9.4", + "typescript": "4.9.5", "wait-port": "1.0.4", "ts-node": "10.9.1", "@playwright/test": "^1.27.1" diff --git a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json index f1e97a01925a..abfb3bfea914 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json +++ b/packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/package.json @@ -16,7 +16,7 @@ "react-dom": "18.2.0", "react-router-dom": "^6.4.1", "react-scripts": "5.0.1", - "typescript": "4.4.2", + "typescript": "4.9.5", "web-vitals": "2.1.0" }, "scripts": { diff --git a/packages/e2e-tests/test-applications/standard-frontend-react/package.json b/packages/e2e-tests/test-applications/standard-frontend-react/package.json index d8f6db397dcd..8ea59b80e55a 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react/package.json +++ b/packages/e2e-tests/test-applications/standard-frontend-react/package.json @@ -15,7 +15,7 @@ "react-dom": "18.2.0", "react-router-dom": "^6.4.1", "react-scripts": "5.0.1", - "typescript": "4.4.2", + "typescript": "4.9.5", "web-vitals": "2.1.0" }, "scripts": { diff --git a/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json b/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json index c3f5f2b89166..2f2e72c8f501 100644 --- a/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json +++ b/packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json @@ -8,6 +8,13 @@ "testCommand": "pnpm test" } ], + "versions": [ + { + "dependencyOverrides": { + "typescript": "3.8.3" + } + } + ], "canaryVersions": [ { "dependencyOverrides": { diff --git a/packages/e2e-tests/test-applications/sveltekit/package.json b/packages/e2e-tests/test-applications/sveltekit/package.json index ab1a2c9cac2e..fbd0b19194ea 100644 --- a/packages/e2e-tests/test-applications/sveltekit/package.json +++ b/packages/e2e-tests/test-applications/sveltekit/package.json @@ -22,7 +22,7 @@ "svelte": "^3.54.0", "svelte-check": "^3.0.1", "ts-node": "10.9.1", - "tslib": "^2.4.1", + "tslib": "2.4.1", "typescript": "^5.0.0", "vite": "^4.2.0", "wait-port": "1.0.4" diff --git a/packages/ember/package.json b/packages/ember/package.json index 310df7417630..d3052b6540f4 100644 --- a/packages/ember/package.json +++ b/packages/ember/package.json @@ -75,7 +75,6 @@ "loader.js": "~4.7.0", "qunit": "~2.19.2", "qunit-dom": "~2.0.0", - "typescript": "~4.5.2", "webpack": "~5.74.0" }, "engines": { diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 4eba80816471..edf9d38d54b6 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -16,6 +16,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -40,7 +43,9 @@ "build:plugin": "tsc -p tsconfig.plugin.json", "build:transpile": "run-p build:rollup build:plugin", "build:rollup": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/hub/package.json b/packages/hub/package.json index 11735b6a921a..1e42ac903903 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -19,13 +22,15 @@ "@sentry/core": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "scripts": { "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/integration-shims/package.json b/packages/integration-shims/package.json index 0c454c040012..0d437f3c77e4 100644 --- a/packages/integration-shims/package.json +++ b/packages/integration-shims/package.json @@ -5,12 +5,17 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "sideEffects": false, "private": true, "scripts": { "build": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:dev": "yarn build", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "run-p build:watch", diff --git a/packages/integrations/package.json b/packages/integrations/package.json index 5cb02c8f95d4..d1b2d45f089d 100644 --- a/packages/integrations/package.json +++ b/packages/integrations/package.json @@ -15,11 +15,14 @@ "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "dependencies": { "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", "localforage": "^1.8.1", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "devDependencies": { "@sentry/browser": "7.54.0", @@ -30,7 +33,9 @@ "build:bundle": "ts-node scripts/buildBundles.ts --parallel", "build:dev": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/integrations/test/captureconsole.test.ts b/packages/integrations/test/captureconsole.test.ts index 6ff08df2e46f..be766d5f6c8d 100644 --- a/packages/integrations/test/captureconsole.test.ts +++ b/packages/integrations/test/captureconsole.test.ts @@ -113,7 +113,7 @@ describe('CaptureConsole setup', () => { it('setup should fail gracefully when console is not available', () => { const consoleRef = global.console; - // remove console + // @ts-ignore remove console delete global.console; expect(() => { diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 39e5763808e0..583b36726db3 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -13,6 +13,9 @@ "module": "build/esm/index.server.js", "browser": "build/esm/index.client.js", "types": "build/types/index.types.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -28,7 +31,7 @@ "chalk": "3.0.0", "rollup": "2.78.0", "stacktrace-parser": "^0.1.10", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "devDependencies": { "@types/webpack": "^4.41.31", @@ -49,7 +52,9 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "ts-node scripts/buildRollup.ts", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts", diff --git a/packages/nextjs/src/common/wrapApiHandlerWithSentryVercelCrons.ts b/packages/nextjs/src/common/wrapApiHandlerWithSentryVercelCrons.ts index 3b9bc8ca7045..d324cc2de7c3 100644 --- a/packages/nextjs/src/common/wrapApiHandlerWithSentryVercelCrons.ts +++ b/packages/nextjs/src/common/wrapApiHandlerWithSentryVercelCrons.ts @@ -16,13 +16,13 @@ export function wrapApiHandlerWithSentryVercelCrons { + apply: (originalFunction, thisArg, args: any[]) => { return runWithAsyncContext(() => { if (!args || !args[0]) { return originalFunction.apply(thisArg, args); } - const [req] = args; + const [req] = args as [NextApiRequest | EdgeRequest]; let maybePromiseResult; const cronsKey = 'nextUrl' in req ? req.nextUrl.pathname : req.url; diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 0bb42f98b7ec..174260a6ad6b 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -180,8 +180,7 @@ export function constructWebpackConfigFunction( } } } catch (e) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (e.code === 'ENOENT') { + if ((e as { code: string }).code === 'ENOENT') { // noop if file does not exist } else { // log but noop diff --git a/packages/nextjs/test/integration/package.json b/packages/nextjs/test/integration/package.json index 5c55363fe714..a382ac88f62c 100644 --- a/packages/nextjs/test/integration/package.json +++ b/packages/nextjs/test/integration/package.json @@ -21,7 +21,7 @@ "@types/react": "17.0.47", "@types/react-dom": "17.0.17", "nock": "^13.1.0", - "typescript": "^4.2.4", + "typescript": "4.9.5", "yargs": "^16.2.0" }, "resolutions": { diff --git a/packages/nextjs/test/serverSdk.test.ts b/packages/nextjs/test/serverSdk.test.ts index 1d2dd60d053c..8e73f71b3771 100644 --- a/packages/nextjs/test/serverSdk.test.ts +++ b/packages/nextjs/test/serverSdk.test.ts @@ -21,6 +21,7 @@ function findIntegrationByName(integrations: Integration[] = [], name: string): describe('Server init()', () => { afterEach(() => { jest.clearAllMocks(); + // @ts-ignore for testing delete GLOBAL_OBJ.__SENTRY__; delete process.env.VERCEL; }); diff --git a/packages/node-integration-tests/utils/run-tests.ts b/packages/node-integration-tests/utils/run-tests.ts index f29aa1a2399b..2c6715f451ab 100644 --- a/packages/node-integration-tests/utils/run-tests.ts +++ b/packages/node-integration-tests/utils/run-tests.ts @@ -13,7 +13,7 @@ const workers = os.cpus().map(async (_, i) => { while (testPaths.length > 0) { const testPath = testPaths.pop(); console.log(`(Worker ${i}) Running test "${testPath}"`); - await new Promise(resolve => { + await new Promise(resolve => { const jestProcess = childProcess.spawn('jest', ['--runTestsByPath', testPath as string, '--forceExit']); // We're collecting the output and logging it all at once instead of inheriting stdout and stderr, so that diff --git a/packages/node/package.json b/packages/node/package.json index e8fa1e297fca..ebe45fe4eae9 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -23,7 +26,7 @@ "cookie": "^0.4.1", "https-proxy-agent": "^5.0.0", "lru_map": "^0.3.3", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "devDependencies": { "@types/cookie": "0.3.2", @@ -38,7 +41,9 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/node/test/index.test.ts b/packages/node/test/index.test.ts index 8b035dff7b03..ab9bd41adaf9 100644 --- a/packages/node/test/index.test.ts +++ b/packages/node/test/index.test.ts @@ -239,7 +239,7 @@ describe('SentryNode', () => { try { throw new Error('cause'); } catch (c) { - e.cause = c; + (e as any).cause = c; captureException(e); } } diff --git a/packages/node/test/utils.test.ts b/packages/node/test/utils.test.ts index 6c8bb3627852..0a62cf011c92 100644 --- a/packages/node/test/utils.test.ts +++ b/packages/node/test/utils.test.ts @@ -38,7 +38,7 @@ describe('deepReadDirSync', () => { expect(deepReadDirSync(dirPath)).toEqual([]); done(); } catch (error) { - done(error); + done(error as Error); } }); }); diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index b11a918835f8..410121e47703 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -38,7 +41,9 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/overhead-metrics/package.json b/packages/overhead-metrics/package.json index ad7430f77962..b309ca6aa32b 100644 --- a/packages/overhead-metrics/package.json +++ b/packages/overhead-metrics/package.json @@ -32,7 +32,7 @@ "playwright-core": "^1.29.1", "simple-git": "^3.16.0", "simple-statistics": "^7.8.0", - "typescript": "^4.9.4" + "typescript": "4.9.5" }, "devDependencies": { "ts-node": "^10.9.1" diff --git a/packages/react/package.json b/packages/react/package.json index 2691ddd5ddfc..77a8af0e0552 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -20,7 +23,7 @@ "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", "hoist-non-react-statics": "^3.3.2", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "peerDependencies": { "react": "15.x || 16.x || 17.x || 18.x" @@ -54,7 +57,9 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/react/test/reactrouterv6.4.test.tsx b/packages/react/test/reactrouterv6.4.test.tsx index fe91dab07979..a01da694ce2f 100644 --- a/packages/react/test/reactrouterv6.4.test.tsx +++ b/packages/react/test/reactrouterv6.4.test.tsx @@ -63,6 +63,7 @@ describe('React Router v6.4', () => { }, ); + // @ts-ignore router is fine render(); expect(mockStartTransaction).toHaveBeenCalledTimes(1); @@ -98,6 +99,7 @@ describe('React Router v6.4', () => { }, ); + // @ts-ignore router is fine render(); expect(mockStartTransaction).toHaveBeenCalledTimes(2); @@ -135,6 +137,7 @@ describe('React Router v6.4', () => { }, ); + // @ts-ignore router is fine render(); expect(mockStartTransaction).toHaveBeenCalledTimes(2); @@ -172,6 +175,7 @@ describe('React Router v6.4', () => { }, ); + // @ts-ignore router is fine render(); expect(mockStartTransaction).toHaveBeenCalledTimes(2); @@ -221,6 +225,7 @@ describe('React Router v6.4', () => { }, ); + // @ts-ignore router is fine render(); expect(mockStartTransaction).toHaveBeenCalledTimes(2); @@ -254,6 +259,7 @@ describe('React Router v6.4', () => { }, ); + // @ts-ignore router is fine render(); expect(mockStartTransaction).toHaveBeenCalledTimes(1); diff --git a/packages/remix/package.json b/packages/remix/package.json index 886ce88b4849..bab01e01513d 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -16,6 +16,9 @@ "module": "build/esm/index.server.js", "browser": "build/esm/index.client.js", "types": "build/types/index.types.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -26,7 +29,7 @@ "@sentry/react": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^1.9.3", + "tslib": "^2.4.1 || ^1.9.3", "yargs": "^17.6.0" }, "devDependencies": { @@ -44,7 +47,9 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/remix/src/utils/instrumentServer.ts b/packages/remix/src/utils/instrumentServer.ts index 7fbff4bb6bd8..14ccad126af8 100644 --- a/packages/remix/src/utils/instrumentServer.ts +++ b/packages/remix/src/utils/instrumentServer.ts @@ -19,6 +19,7 @@ import type { CreateRequestHandlerFunction, DataFunction, DataFunctionArgs, + EntryContext, HandleDocumentRequestFunction, ReactRouterDomPkg, RemixRequest, @@ -56,7 +57,7 @@ async function extractResponseError(response: Response): Promise { return responseData; } -async function captureRemixServerException(err: Error, name: string, request: Request): Promise { +async function captureRemixServerException(err: unknown, name: string, request: Request): Promise { // Skip capturing if the thrown error is not a 5xx response // https://remix.run/docs/en/v1/api/conventions#throwing-responses-in-loaders if (isResponse(err) && err.status < 500) { @@ -112,7 +113,7 @@ function makeWrappedDocumentRequestFunction( request: Request, responseStatusCode: number, responseHeaders: Headers, - context: Record, + context: EntryContext, loadContext?: Record, ): Promise { let res: Response; diff --git a/packages/remix/src/utils/serverAdapters/express.ts b/packages/remix/src/utils/serverAdapters/express.ts index 59cb299e489b..000ad3a00b15 100644 --- a/packages/remix/src/utils/serverAdapters/express.ts +++ b/packages/remix/src/utils/serverAdapters/express.ts @@ -142,7 +142,7 @@ async function finishSentryProcessing(res: AugmentedExpressResponse): Promise { + await new Promise(resolve => { setImmediate(() => { transaction.finish(); resolve(); diff --git a/packages/remix/test/integration/package.json b/packages/remix/test/integration/package.json index 3899f1acddad..687899c3fb59 100644 --- a/packages/remix/test/integration/package.json +++ b/packages/remix/test/integration/package.json @@ -20,7 +20,7 @@ "@types/react": "^17.0.47", "@types/react-dom": "^17.0.17", "nock": "^13.1.0", - "typescript": "^4.2.4" + "typescript": "4.9.5" }, "resolutions": { "@sentry/browser": "file:../../../browser", diff --git a/packages/replay-worker/package.json b/packages/replay-worker/package.json index 77a5c0a03db6..053df3e0d967 100644 --- a/packages/replay-worker/package.json +++ b/packages/replay-worker/package.json @@ -5,12 +5,17 @@ "main": "build/npm/esm/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "sideEffects": false, "private": true, "scripts": { "build": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.worker.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:dev": "yarn build", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "run-p build:watch", @@ -38,7 +43,7 @@ "homepage": "https://docs.sentry.io/platforms/javascript/session-replay/", "devDependencies": { "@types/pako": "^2.0.0", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "dependencies": { "pako": "^2.1.0" diff --git a/packages/replay-worker/src/handleMessage.ts b/packages/replay-worker/src/handleMessage.ts index 958797e82cbb..2a00f54a581f 100644 --- a/packages/replay-worker/src/handleMessage.ts +++ b/packages/replay-worker/src/handleMessage.ts @@ -54,7 +54,7 @@ export function handleMessage(e: MessageEvent): void { id, method, success: false, - response: err.message, + response: (err as Error).message, }); // eslint-disable-next-line no-console diff --git a/packages/replay/.eslintignore b/packages/replay/.eslintignore index c76c6c2d64d1..82f028e93347 100644 --- a/packages/replay/.eslintignore +++ b/packages/replay/.eslintignore @@ -4,3 +4,5 @@ demo/build/ # TODO: Check if we can re-introduce linting in demo demo metrics +# For whatever reason, the eslint-ignore comment in this file is not working, so skipping this file +src/types/rrweb.ts diff --git a/packages/replay/package.json b/packages/replay/package.json index 6b18a5de02a7..72898d72518f 100644 --- a/packages/replay/package.json +++ b/packages/replay/package.json @@ -5,13 +5,18 @@ "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "sideEffects": false, "scripts": { "build": "run-p build:transpile build:types build:bundle", "build:transpile": "rollup -c rollup.npm.config.js", "build:bundle": "rollup -c rollup.bundle.config.js", "build:dev": "run-p build:transpile build:types", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch", "build:dev:watch": "run-p build:transpile:watch build:types:watch", "build:transpile:watch": "yarn build:transpile --watch", @@ -48,7 +53,7 @@ "@sentry-internal/rrweb": "1.108.0", "@sentry-internal/rrweb-snapshot": "1.108.0", "jsdom-worker": "^0.2.1", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "dependencies": { "@sentry/core": "7.54.0", diff --git a/packages/replay/src/coreHandlers/handleFetch.ts b/packages/replay/src/coreHandlers/handleFetch.ts index 1358701ab8f3..36ec538f1b28 100644 --- a/packages/replay/src/coreHandlers/handleFetch.ts +++ b/packages/replay/src/coreHandlers/handleFetch.ts @@ -21,7 +21,7 @@ export function handleFetch(handlerData: HandlerDataFetch): null | ReplayPerform name: url, data: { method, - statusCode: response && (response as Response).status, + statusCode: response ? (response as Response).status : undefined, }, }; } diff --git a/packages/replay/src/util/createPerformanceEntries.ts b/packages/replay/src/util/createPerformanceEntries.ts index 1dbb07829fb3..f7b02aa324be 100644 --- a/packages/replay/src/util/createPerformanceEntries.ts +++ b/packages/replay/src/util/createPerformanceEntries.ts @@ -9,8 +9,6 @@ import type { LargestContentfulPaintData, NavigationData, PaintData, - PerformanceNavigationTiming, - PerformancePaintTiming, ReplayPerformanceEntry, ResourceData, } from '../types'; diff --git a/packages/replay/src/util/dedupePerformanceEntries.ts b/packages/replay/src/util/dedupePerformanceEntries.ts index 17933710c91f..22ac369e90a2 100644 --- a/packages/replay/src/util/dedupePerformanceEntries.ts +++ b/packages/replay/src/util/dedupePerformanceEntries.ts @@ -1,5 +1,3 @@ -import type { PerformanceNavigationTiming, PerformancePaintTiming } from '../types'; - const NAVIGATION_ENTRY_KEYS: Array = [ 'name', 'type', diff --git a/packages/replay/test/fixtures/performanceEntry/lcp.ts b/packages/replay/test/fixtures/performanceEntry/lcp.ts index 4db2eb53f565..891e133a981f 100644 --- a/packages/replay/test/fixtures/performanceEntry/lcp.ts +++ b/packages/replay/test/fixtures/performanceEntry/lcp.ts @@ -1,5 +1,3 @@ -import type { PerformancePaintTiming } from '../../../src/types'; - export function PerformanceEntryLcp(obj?: Partial): PerformancePaintTiming { const entry = { name: '', diff --git a/packages/replay/test/fixtures/performanceEntry/navigation.ts b/packages/replay/test/fixtures/performanceEntry/navigation.ts index d76ebce86538..476ae1d29098 100644 --- a/packages/replay/test/fixtures/performanceEntry/navigation.ts +++ b/packages/replay/test/fixtures/performanceEntry/navigation.ts @@ -1,5 +1,3 @@ -import type { PerformanceNavigationTiming } from '../../../src/types'; - export function PerformanceEntryNavigation(obj?: Partial): PerformanceNavigationTiming { const entry = { activationStart: 0, @@ -33,10 +31,10 @@ export function PerformanceEntryNavigation(obj?: Partial void { const performance = getBrowserPerformanceAPI(); if (performance && browserPerformanceTimeOrigin) { + // @ts-ignore we want to make sure all of these are available, even if TS is sure they are if (performance.mark) { WINDOW.performance.mark('sentry-tracing-init'); } diff --git a/packages/tracing-internal/src/browser/web-vitals/lib/getNavigationEntry.ts b/packages/tracing-internal/src/browser/web-vitals/lib/getNavigationEntry.ts index 9aaa8939b6dc..75ec564eb5de 100644 --- a/packages/tracing-internal/src/browser/web-vitals/lib/getNavigationEntry.ts +++ b/packages/tracing-internal/src/browser/web-vitals/lib/getNavigationEntry.ts @@ -31,6 +31,7 @@ const getNavigationEntryFromPerformanceTiming = (): NavigationTimingPolyfillEntr for (const key in timing) { if (key !== 'navigationStart' && key !== 'toJSON') { + // eslint-disable-next-line deprecation/deprecation navigationEntry[key] = Math.max((timing[key as keyof PerformanceTiming] as number) - timing.navigationStart, 0); } } diff --git a/packages/tracing-internal/src/node/integrations/prisma.ts b/packages/tracing-internal/src/node/integrations/prisma.ts index 20a84aa36aaf..105183857d15 100644 --- a/packages/tracing-internal/src/node/integrations/prisma.ts +++ b/packages/tracing-internal/src/node/integrations/prisma.ts @@ -40,7 +40,7 @@ interface PrismaClient { } function isValidPrismaClient(possibleClient: unknown): possibleClient is PrismaClient { - return possibleClient && !!(possibleClient as PrismaClient)['$use']; + return !!possibleClient && !!(possibleClient as PrismaClient)['$use']; } /** Tracing integration for @prisma/client package */ diff --git a/packages/tracing/package.json b/packages/tracing/package.json index 5dcf9dce72c2..713b7b748854 100644 --- a/packages/tracing/package.json +++ b/packages/tracing/package.json @@ -12,6 +12,9 @@ "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -30,7 +33,9 @@ "build": "run-p build:transpile build:types", "build:dev": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "run-p build:transpile:watch build:types:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/types/package.json b/packages/types/package.json index 6a861891034d..987f98a1db26 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -19,7 +22,9 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 38a78d6cb905..e4d06c2ae4b0 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -11,7 +11,7 @@ "access": "public" }, "peerDependencies": { - "typescript": "3.8.3" + "typescript": "4.9.5" }, "scripts": { "clean": "yarn rimraf sentry-internal-typescript-*.tgz", diff --git a/packages/utils/package.json b/packages/utils/package.json index 984e5ff96602..e8e0af78989f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -12,12 +12,15 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, "dependencies": { "@sentry/types": "7.54.0", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "devDependencies": { "@types/array.prototype.flat": "^1.2.1", @@ -29,7 +32,9 @@ "build:dev": "yarn build", "build:transpile": "yarn ts-node scripts/buildRollup.ts", "build:transpile:uncached": "yarn ts-node scripts/buildRollup.ts", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/utils/src/envelope.ts b/packages/utils/src/envelope.ts index 66adb7e78ebd..e91aefdbab5b 100644 --- a/packages/utils/src/envelope.ts +++ b/packages/utils/src/envelope.ts @@ -34,7 +34,7 @@ export function createEnvelope(headers: E[0], items: E[1] = */ export function addItemToEnvelope(envelope: E, newItem: E[1][number]): E { const [headers, items] = envelope; - return [headers, [...items, newItem]] as E; + return [headers, [...items, newItem]] as unknown as E; } /** diff --git a/packages/utils/test/envelope.test.ts b/packages/utils/test/envelope.test.ts index 9649da0e2108..10cdcc2cab73 100644 --- a/packages/utils/test/envelope.test.ts +++ b/packages/utils/test/envelope.test.ts @@ -1,4 +1,4 @@ -import type { EventEnvelope } from '@sentry/types'; +import type { Event, EventEnvelope } from '@sentry/types'; import { TextDecoder, TextEncoder } from 'util'; const encoder = new TextEncoder(); @@ -68,8 +68,8 @@ describe('envelope', () => { }); it("doesn't throw when being passed a an envelope that contains a circular item payload", () => { - const chicken: { egg?: unknown } = {}; - const egg = { chicken }; + const chicken: { egg?: any } = {}; + const egg = { chicken } as unknown as Event; chicken.egg = chicken; const env = createEnvelope({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, [ diff --git a/packages/utils/test/worldwide.test.ts b/packages/utils/test/worldwide.test.ts index 6137c95c093b..52203a248d69 100644 --- a/packages/utils/test/worldwide.test.ts +++ b/packages/utils/test/worldwide.test.ts @@ -3,6 +3,7 @@ import { GLOBAL_OBJ } from '../src/worldwide'; describe('GLOBAL_OBJ', () => { test('should return the same object', () => { const backup = global.process; + // @ts-ignore for testing delete global.process; const first = GLOBAL_OBJ; const second = GLOBAL_OBJ; diff --git a/packages/vue/package.json b/packages/vue/package.json index be825851fced..75376ef5c108 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/types/index.d.ts": ["build/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -20,7 +23,7 @@ "@sentry/core": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "peerDependencies": { "vue": "2.x || 3.x" @@ -32,7 +35,9 @@ "build": "run-p build:transpile build:types", "build:dev": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "run-p build:transpile:watch build:types:watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", diff --git a/packages/wasm/package.json b/packages/wasm/package.json index d4e3ea624503..8baf2bf5851b 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -12,6 +12,9 @@ "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", + "typesVersions": { + "<4.9": { "build/npm/types/index.d.ts": ["build/npm/types-ts3.8/index.d.ts"] } + }, "publishConfig": { "access": "public" }, @@ -19,14 +22,16 @@ "@sentry/browser": "7.54.0", "@sentry/types": "7.54.0", "@sentry/utils": "7.54.0", - "tslib": "^1.9.3" + "tslib": "^2.4.1 || ^1.9.3" }, "scripts": { "build": "run-p build:transpile build:bundle build:types", "build:bundle": "rollup --config rollup.bundle.config.js", "build:dev": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.npm.config.js", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "run-s build:types:core build:types:downlevel", + "build:types:core": "tsc -p tsconfig.types.json", + "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", "build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch", "build:bundle:watch": "rollup --config rollup.bundle.config.js --watch", "build:dev:watch": "run-p build:transpile:watch build:types:watch", diff --git a/scripts/ensure-bundle-deps.ts b/scripts/ensure-bundle-deps.ts index 8be6377ee4e1..4e61a6ecf993 100644 --- a/scripts/ensure-bundle-deps.ts +++ b/scripts/ensure-bundle-deps.ts @@ -129,7 +129,7 @@ function checkForBundleDeps(packagesDir: string, dependencyDirs: string[]): bool * Wait the given number of milliseconds before continuing. */ async function sleep(ms: number): Promise { - await new Promise(resolve => + await new Promise(resolve => setTimeout(() => { resolve(); }, ms), diff --git a/scripts/verify-packages-versions.js b/scripts/verify-packages-versions.js index 9e24e8090096..9c54cf2020c4 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 = '3.8.3'; +const TYPESCRIPT_VERSION = '4.9.5'; if (pkg.devDependencies.typescript !== TYPESCRIPT_VERSION) { console.error(` diff --git a/yarn.lock b/yarn.lock index b4ab26edf619..224622dc7189 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11128,6 +11128,15 @@ dotenv@~10.0.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== +downlevel-dts@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/downlevel-dts/-/downlevel-dts-0.11.0.tgz#514a2d723009c5845730c1db6c994484c596ed9c" + integrity sha512-vo835pntK7kzYStk7xUHDifiYJvXxVhUapt85uk2AI94gUUAQX9HNRtrcMHNSc3YHJUEHGbYIGsM99uIbgAtxw== + dependencies: + semver "^7.3.2" + shelljs "^0.8.3" + typescript next + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" @@ -24140,7 +24149,7 @@ shell-quote@1.7.2, shell-quote@^1.6.1: resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2" integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg== -shelljs@^0.8.4: +shelljs@^0.8.3, shelljs@^0.8.4: version "0.8.5" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c" integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow== @@ -26244,20 +26253,20 @@ tslib@2.3.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== -tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: +tslib@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e" + integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA== + +tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" - integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== - -tslib@^2.2.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" - integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== +tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.2.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.4.1, "tslib@^2.4.1 || ^1.9.3": + version "2.5.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.2.tgz#1b6f07185c881557b0ffa84b111a0106989e8338" + integrity sha512-5svOrSA2w3iGFDs1HibEVBGbDrAY82bFQ3HZ3ixB+88nsbsWQoKqDRb5UBYAUPEzbBn6dAp5gRNXglySbx1MlA== tsutils@^3.0.0, tsutils@^3.17.1, tsutils@^3.21.0: version "3.21.0" @@ -26405,45 +26414,30 @@ typescript-memoize@^1.0.0-alpha.3, typescript-memoize@^1.0.1: resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.0.1.tgz#0a8199aa28f6fe18517f6e9308ef7bfbe9a98d59" integrity sha512-oJNge1qUrOK37d5Y6Ly2txKeuelYVsFtNF6U9kXIN7juudcQaHJQg2MxLOy0CqtkW65rVDYuTCOjnSIVPd8z3w== -typescript@3.8.3: - version "3.8.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" - integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w== - typescript@4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== -typescript@4.3.5, typescript@~4.3.5: +typescript@4.3.5: version "4.3.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== -"typescript@^3 || ^4", typescript@^4.5.2: - version "4.9.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db" - integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA== - -typescript@^3.9.5, typescript@^3.9.7: - version "3.9.9" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.9.tgz#e69905c54bc0681d0518bd4d587cc6f2d0b1a674" - integrity sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w== - -typescript@^4.9.3, typescript@^4.9.4: +typescript@4.9.5, "typescript@^3 || ^4": version "4.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== -typescript@~4.0.2: - version "4.0.8" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.8.tgz#5739105541db80a971fdbd0d56511d1a6f17d37f" - integrity sha512-oz1765PN+imfz1MlZzSZPtC/tqcwsCyIYA8L47EkRnRW97ztRk83SzMiWLrnChC0vqoYxSU1fcFUDA5gV/ZiPg== - -typescript@~4.5.2: - version "4.5.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" - integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== +typescript@^3.9.5, typescript@^3.9.7: + version "3.9.10" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" + integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== + +typescript@next: + version "5.2.0-dev.20230530" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.0-dev.20230530.tgz#4251ade97a9d8a86850c4d5c3c4f3e1cb2ccf52c" + integrity sha512-bIoMajCZWzLB+pWwncaba/hZc6dRnw7x8T/fenOnP9gYQB/gc4xdm48AXp5SH5I/PvvSeZ/dXkUMtc8s8BiDZw== typeson-registry@^1.0.0-alpha.20: version "1.0.0-alpha.39"