Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking API change in types from 12.0.4 to 12.0.5 #32123

Closed
bryanjswift opened this issue Dec 4, 2021 · 3 comments · Fixed by #32134
Closed

Breaking API change in types from 12.0.4 to 12.0.5 #32123

bryanjswift opened this issue Dec 4, 2021 · 3 comments · Fixed by #32134
Labels
bug Issue was opened via the bug report template.

Comments

@bryanjswift
Copy link

What version of Next.js are you using?

12.0.5

What version of Node.js are you using?

14.18.1

What browser are you using?

Not applicable

What operating system are you using?

macOS

How are you deploying your application?

using custom server

Describe the Bug

The update from 12.0.4 to 12.0.5 including a breaking API change when calling the createServer function.

In 12.0.4 with TypeScript this compiles fine:

const app = next({
  dir: './src',
  dev: process.env.NODE_ENV !== 'production',
  conf: {
    compress: false,
  } as NextServerOptions['conf'],
  quiet: false,
});
const requestHandler = app.getRequestHandler();

In version 12.0.5 the above generates the following TypeError:

src/index.ts:9:3 - error TS2322: Type '{ compress: false; }' is not assignable to type 'NextConfigComplete'.
  Type '{ compress: false; }' is missing the following properties from type 'Required<NextConfig>': i18n, eslint, typescr
ipt, headers, and 33 more.

9   conf: {
    ~~~~

  ../../node_modules/next/dist/server/next-server.d.ts:34:5
    34     conf: NextConfigComplete;
           ~~~~
    The expected type comes from property 'conf' which is declared here on type 'Partial<Options>'


Found 1 error.

Expected Behavior

Existing createServer configuration would continue to work in patch versions, especially when the release notes say "This upgrade is completely backward-compatible and recommended for all users on versions below 12.0.5. A backport of the patch to Next.js 11 will be available later today."

To Reproduce

  1. npx create-next-app@latest --typescript

  2. Change version of next and eslint-config-next in generated package.json to 12.0.4

  3. Run yarn to get the downgraded version

  4. Create server.ts with following contents

     import next from 'next';
     const app = next({
       dir: '.',
       dev: process.env.NODE_ENV !== 'production',
       conf: {
         compress: false,
       },
       quiet: false,
     });
     const requestHandler = app.getRequestHandler();
    
  5. Execute yarn run tsc to check types, there should be no type errors

  6. Change version of next and eslint-config-next in generated package.json to 12.0.5

  7. Run yarn to get the version 12.0.5

  8. Execute yarn run tsc to check types, receiving the following error

     server.ts:5:3 - error TS2322: Type '{ compress: false; }' is not assignable to type 'NextConfigComplete'.
       Type '{ compress: false; }' is missing the following properties from type 'Required<NextConfig>': i18n, eslint, typescript, headers, and 33 more.
     
     5   conf: {
         ~~~~
     
       node_modules/next/dist/server/next-server.d.ts:34:5
         34     conf: NextConfigComplete;
                ~~~~
         The expected type comes from property 'conf' which is declared here on type 'Partial<Options>'
     
     
     Found 1 error.
     
     error Command failed with exit code 2.
    
@bryanjswift bryanjswift added the bug Issue was opened via the bug report template. label Dec 4, 2021
tbergquist-godaddy added a commit to tbergquist-godaddy/monorepo that referenced this issue Dec 4, 2021
next 12.0.5 breaks typescript typecheck
vercel/next.js#32123
kodiakhq bot pushed a commit to tbergquist-godaddy/monorepo that referenced this issue Dec 4, 2021
next 12.0.5 breaks typescript typecheck
vercel/next.js#32123
@kodiakhq kodiakhq bot closed this as completed in #32134 Dec 4, 2021
kodiakhq bot pushed a commit that referenced this issue Dec 4, 2021
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
@ijjk
Copy link
Member

ijjk commented Dec 5, 2021

Hi, this has been updated in v12.0.7 of Next.js, please update and give it a try!

@bryanjswift
Copy link
Author

Hi, this has been updated in v12.0.7 of Next.js, please update and give it a try!

Thanks for the quick fix!

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
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: vercel#32123
x-ref: vercel#31858
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants