Skip to content

Commit 888c14a

Browse files
meeqkamilogorek
authored andcommitted
fix(nextjs): Improve NextConfigExports compatibility
Passing type `import('next/dist/next-server/server/config').NextConfig` into `withSentryConfig` results in a type-checking error (`ts(2345)`): ``` Argument of type 'NextConfig' is not assignable to parameter of type 'NextConfigExports'. Types of property 'experimental' are incompatible. Type '{ cpus?: number; plugins?: boolean; profiling?: boolean; sprFlushToDisk?: boolean; reactMode?: "legacy" | "concurrent" | "blocking"; workerThreads?: boolean; pageEnv?: boolean; optimizeImages?: boolean; ... 13 more ...; gzipSize?: boolean; }' is not assignable to type '{ plugins: boolean; }'. Property 'plugins' is optional in type '{ cpus?: number; plugins?: boolean; profiling?: boolean; sprFlushToDisk?: boolean; reactMode?: "legacy" | "concurrent" | "blocking"; workerThreads?: boolean; pageEnv?: boolean; optimizeImages?: boolean; ... 13 more ...; gzipSize?: boolean; }' but required in type '{ plugins: boolean; }'. ```
1 parent 925c114 commit 888c14a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/nextjs/src/utils/config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { dropUndefinedKeys, logger } from '@sentry/utils';
33
import defaultWebpackPlugin, { SentryCliPluginOptions } from '@sentry/webpack-plugin';
44
import * as SentryWebpackPlugin from '@sentry/webpack-plugin';
55
import * as fs from 'fs';
6+
import { NextConfig } from 'next/dist/next-server/server/config';
67
import * as path from 'path';
78

89
const SENTRY_CLIENT_CONFIG_FILE = './sentry.client.config.js';
@@ -110,9 +111,7 @@ const injectSentry = async (origEntryProperty: EntryProperty, isServer: boolean)
110111
return newEntryProperty;
111112
};
112113

113-
type NextConfigExports = {
114-
experimental?: { plugins: boolean };
115-
plugins?: string[];
114+
type NextConfigExports = Partial<NextConfig> & {
116115
productionBrowserSourceMaps?: boolean;
117116
webpack?: WebpackExport;
118117
};
@@ -125,7 +124,7 @@ type NextConfigExports = {
125124
* @returns The modified config to be exported
126125
*/
127126
export function withSentryConfig(
128-
providedExports: NextConfigExports = {},
127+
providedExports: Partial<NextConfig> = {},
129128
providedSentryWebpackPluginOptions: Partial<SentryCliPluginOptions> = {},
130129
): NextConfigExports {
131130
const defaultSentryWebpackPluginOptions = dropUndefinedKeys({

0 commit comments

Comments
 (0)