Skip to content

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

@eweilow

Description

@eweilow

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions