Skip to content

Commit eaffd72

Browse files
authored
fix(nuxt): Use SentryNuxtServerOptions type for server init (#15441)
We actually have a concrete type for the `init` on the server-side. However, this type was not used so far. Additionally, I removed the `Omit` of `'app'` as there is no `'app'` on the Node types anyway.
1 parent 8fc56d8 commit eaffd72

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/nuxt/src/common/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type { SentryRollupPluginOptions } from '@sentry/rollup-plugin';
33
import type { SentryVitePluginOptions } from '@sentry/vite-plugin';
44
import type { init as initVue } from '@sentry/vue';
55

6-
// Omitting 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this)
6+
// Omitting Vue 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this)
7+
// Adding `& object` helps TS with inferring that this is not `undefined` but an object type
78
export type SentryNuxtClientOptions = Omit<Parameters<typeof initVue>[0] & object, 'app'>;
8-
export type SentryNuxtServerOptions = Omit<Parameters<typeof initNode>[0] & object, 'app'>;
9+
export type SentryNuxtServerOptions = Parameters<typeof initNode>[0] & object;
910

1011
type SourceMapsOptions = {
1112
/**

packages/nuxt/src/index.types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { Client, Integration, Options, StackParser } from '@sentry/core';
2-
import type { SentryNuxtClientOptions } from './common/types';
2+
import type { SentryNuxtClientOptions, SentryNuxtServerOptions } from './common/types';
33
import type * as clientSdk from './index.client';
4-
import type * as serverSdk from './index.server';
54

65
// We export everything from both the client part of the SDK and from the server part. Some of the exports collide,
76
// which is not allowed, unless we re-export the colliding exports in this file - which we do below.
87
export * from './index.client';
98
export * from './index.server';
109

1110
// re-export colliding types
12-
export declare function init(options: Options | SentryNuxtClientOptions | serverSdk.NodeOptions): Client | undefined;
11+
export declare function init(options: Options | SentryNuxtClientOptions | SentryNuxtServerOptions): Client | undefined;
1312
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
1413
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
1514
export declare const getDefaultIntegrations: (options: Options) => Integration[];

0 commit comments

Comments
 (0)