From 7da389728f4bd8b22ee11466a0bd68e1781f9003 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Tue, 18 Feb 2025 17:05:32 +0100 Subject: [PATCH 1/2] fix(nuxt): Use `SentryNuxtServerOptions` type for server init --- packages/nuxt/src/common/types.ts | 4 ++-- packages/nuxt/src/index.types.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/nuxt/src/common/types.ts b/packages/nuxt/src/common/types.ts index 62496001273b..b92a2bb72001 100644 --- a/packages/nuxt/src/common/types.ts +++ b/packages/nuxt/src/common/types.ts @@ -3,9 +3,9 @@ import type { SentryRollupPluginOptions } from '@sentry/rollup-plugin'; import type { SentryVitePluginOptions } from '@sentry/vite-plugin'; import type { init as initVue } from '@sentry/vue'; -// Omitting 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this) +// Omitting Vue 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this) export type SentryNuxtClientOptions = Omit[0] & object, 'app'>; -export type SentryNuxtServerOptions = Omit[0] & object, 'app'>; +export type SentryNuxtServerOptions = Parameters[0]; type SourceMapsOptions = { /** diff --git a/packages/nuxt/src/index.types.ts b/packages/nuxt/src/index.types.ts index dc9bf360af9e..b1393a076029 100644 --- a/packages/nuxt/src/index.types.ts +++ b/packages/nuxt/src/index.types.ts @@ -1,7 +1,6 @@ import type { Client, Integration, Options, StackParser } from '@sentry/core'; -import type { SentryNuxtClientOptions } from './common/types'; +import type { SentryNuxtClientOptions, SentryNuxtServerOptions } from './common/types'; import type * as clientSdk from './index.client'; -import type * as serverSdk from './index.server'; // We export everything from both the client part of the SDK and from the server part. Some of the exports collide, // which is not allowed, unless we re-export the colliding exports in this file - which we do below. @@ -9,7 +8,7 @@ export * from './index.client'; export * from './index.server'; // re-export colliding types -export declare function init(options: Options | SentryNuxtClientOptions | serverSdk.NodeOptions): Client | undefined; +export declare function init(options: Options | SentryNuxtClientOptions | SentryNuxtServerOptions): Client | undefined; export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration; export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration; export declare const getDefaultIntegrations: (options: Options) => Integration[]; From c2bea430d53d14cf50ef8b601ab25b6d7c59e0eb Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Wed, 19 Feb 2025 10:30:26 +0100 Subject: [PATCH 2/2] fix type error --- packages/nuxt/src/common/types.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/common/types.ts b/packages/nuxt/src/common/types.ts index b92a2bb72001..02e0b53bac7c 100644 --- a/packages/nuxt/src/common/types.ts +++ b/packages/nuxt/src/common/types.ts @@ -4,8 +4,9 @@ import type { SentryVitePluginOptions } from '@sentry/vite-plugin'; import type { init as initVue } from '@sentry/vue'; // Omitting Vue 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this) +// Adding `& object` helps TS with inferring that this is not `undefined` but an object type export type SentryNuxtClientOptions = Omit[0] & object, 'app'>; -export type SentryNuxtServerOptions = Parameters[0]; +export type SentryNuxtServerOptions = Parameters[0] & object; type SourceMapsOptions = { /**