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
});
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
The option that I see is to maintain types for the configuration object in parallel to this repository, or simply use the configuration untyped.
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.
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.
Any movement on this?
Most helpful comment
Types can be used via JSDoc, it'll help developers to annotate their
next.config.js
files.