Skip to content

Commit 769d680

Browse files
authored
Ensure conf type for createServer is not changed (#32134)
This reverts the type for the `conf` field in `ServerOptions` isn't changed to require all `NextConfig` values as this is a breaking change from what was previously required. We should investigate making sure this field is normalized when it is provided via a user. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Fixes: #32123 x-ref: #31858
1 parent c1a1aa4 commit 769d680

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

packages/next/server/next-server.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { IncomingMessage, ServerResponse } from 'http'
88
import type { LoadComponentsReturnType } from './load-components'
99
import type { MiddlewareManifest } from '../build/webpack/plugins/middleware-plugin'
1010
import type { NextApiRequest, NextApiResponse } from '../shared/lib/utils'
11-
import type { NextConfigComplete } from './config-shared'
11+
import type { NextConfig, NextConfigComplete } from './config-shared'
1212
import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta'
1313
import type { ParsedNextUrl } from '../shared/lib/router/utils/parse-next-url'
1414
import type { ParsedUrl } from '../shared/lib/router/utils/parse-url'
@@ -123,7 +123,7 @@ export interface Options {
123123
/**
124124
* Object containing the configuration next.config.js
125125
*/
126-
conf: NextConfigComplete
126+
conf: NextConfig
127127
/**
128128
* Set to false when the server was created by Next.js
129129
*/
@@ -233,7 +233,9 @@ export default class Server {
233233
this.quiet = quiet
234234
loadEnvConfig(this.dir, dev, Log)
235235

236-
this.nextConfig = conf
236+
// TODO: should conf be normalized to prevent missing
237+
// values from causing issues as this can be user provided
238+
this.nextConfig = conf as NextConfigComplete
237239
this.hostname = hostname
238240
this.port = port
239241

test/production/typescript-basic.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ describe('TypeScript basic', () => {
2424
)
2525
}
2626
`,
27+
'server.ts': `
28+
import next from 'next';
29+
const app = next({
30+
dir: '.',
31+
dev: process.env.NODE_ENV !== 'production',
32+
conf: {
33+
compress: false,
34+
},
35+
quiet: false,
36+
});
37+
const requestHandler = app.getRequestHandler();
38+
`,
2739
},
2840
dependencies: {
2941
typescript: '4.4.3',

0 commit comments

Comments
 (0)