@@ -16,13 +16,15 @@ export function withSentryConfig(
1616 // `defaults` in order to pass them along to the user's function
1717 if ( typeof exportedUserNextConfig === 'function' ) {
1818 return function ( phase : string , defaults : { defaultConfig : NextConfigObject } ) : NextConfigObject {
19- const userNextConfigObject = exportedUserNextConfig ( phase , defaults ) ;
19+ let userNextConfigObject = exportedUserNextConfig ( phase , defaults ) ;
2020
2121 // Next 12.2.3+ warns about non-canonical properties on `userNextConfig`, so grab and then remove the `sentry`
2222 // property there. Where we actually need it is in the webpack config function we're going to create, so pass it
2323 // to `constructWebpackConfigFunction` so that it will be in the created function's closure.
2424 const { sentry : userSentryOptions } = userNextConfigObject ;
2525 delete userNextConfigObject . sentry ;
26+ // Remind TS that there's now no `sentry` property
27+ userNextConfigObject = userNextConfigObject as NextConfigObject ;
2628
2729 return {
2830 ...userNextConfigObject ,
@@ -41,9 +43,11 @@ export function withSentryConfig(
4143 // for a more thorough explanation of what we're doing here.)
4244 const { sentry : userSentryOptions } = exportedUserNextConfig ;
4345 delete exportedUserNextConfig . sentry ;
46+ // Remind TS that there's now no `sentry` property
47+ const userNextConfigObject = exportedUserNextConfig as NextConfigObject ;
4448
4549 return {
46- ...exportedUserNextConfig ,
47- webpack : constructWebpackConfigFunction ( exportedUserNextConfig , userSentryWebpackPluginOptions , userSentryOptions ) ,
50+ ...userNextConfigObject ,
51+ webpack : constructWebpackConfigFunction ( userNextConfigObject , userSentryWebpackPluginOptions , userSentryOptions ) ,
4852 } ;
4953}
0 commit comments