question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create types for the configuration in next.config.js (and the NextConfig type)

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

Since I transpile a next.config.ts to next.config.js, it would be good to have typings for the configuration object. This is what is currently typed as any in https://github.com/zeit/next.js/blob/fce7e4eaee45e89557ceaa81fbd42057f8596e22/packages/next-server/server/next-server.ts#L37

This is also a problem when using the programmatic API, since the conf property on the options given to next is typed as any:

import next from "next";
const app = next({
  conf // any
});

Describe the solution you’d like

The previous types provided by @types/next and @types/next-server can be seen here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/next-server/next-config.d.ts

Perhaps the easiest solution is to type NextConfig with something similar to the version that @types/next-server is based on: https://github.com/zeit/next.js/blob/7.0.0/server/config.js#L9-L20

Describe alternatives you’ve considered

The option that I see is to maintain types for the configuration object in parallel to this repository, or simply use the configuration untyped.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

26reactions
evgenymarkovcommented, Aug 26, 2019

We’re currently not planning on allowing next.config.ts, and I wouldn’t recommend adding an intermediate build step for just one config file.

Types can be used via JSDoc, it’ll help developers to annotate their next.config.js files.

image

8reactions
timneutkenscommented, Aug 10, 2019

We’re currently not planning on allowing next.config.ts, and I wouldn’t recommend adding an intermediate build step for just one config file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create types for the configuration in next.config.js ... - GitHub
Create types for the configuration in next.config.js (and the ... Perhaps the easiest solution is to type NextConfig with something similar ...
Read more >
next.config.js: Introduction
For custom advanced configuration of Next.js, you can create a next.config.js or next.config.mjs file in the root of your project directory (next to ......
Read more >
Customize your Next.JS App using next.config.js ... - YouTube
In this video, we will see how we can use the next. config. js file in our Next.JS applications to take our App...
Read more >
Next.js-config with type checking - flaming.codes
Next.js doesn't support Typescript-types for its config yet, but you can still include some utility typings.
Read more >
Handle environment configuration in Next.js > 9 - Medium
We all know how important is loading different configuration on each ... You'll need to create/update next.config.js. ... }module.exports = nextConfig ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found