Create types for the configuration in next.config.js (and the NextConfig type)
See original GitHub issueFeature 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:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Types can be used via JSDoc, it’ll help developers to annotate their
next.config.js
files.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.