Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[request] better typescript type for next.config.js NextConfig #10254

Closed
bluelovers opened this issue Jan 24, 2020 · 7 comments
Closed

[request] better typescript type for next.config.js NextConfig #10254

bluelovers opened this issue Jan 24, 2020 · 7 comments

Comments

@bluelovers
Copy link

Feature request

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

i only see this, but any not a good type

declare type NextConfig = any;

if have a type/interface for this
we can more easy write a next.config or a config plugin

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

@eps1lon
Copy link
Member

eps1lon commented Apr 12, 2020

Just leaving my use case here after #8044 was closed without much considerations:

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

Documentation for config is incomplete and spread out. In-editor autocomplete solves this via types.

Describe the solution you'd like

Export types of next.config.js so that people can use JSDOC to get autcomplete for the config via

/**
 * @type {import('next').Config}
 */
const config = {
  // your config here
};
module.exports = config;

Describe alternatives you've considered

Declare the types locally starting from https://github.com/zeit/next.js/blob/287961ed9142a53f8e9a23bafb2f31257339ea98/packages/next/next-server/server/config.ts#L12-L65

@jgoux
Copy link

jgoux commented May 6, 2020

I just used a similar approach for typing relay's configuration file :

// @ts-check

/**
 * @type import("relay-compiler/lib/bin/RelayCompilerMain").Config
 */
module.exports = {
  // free auto-complete and type-checking yay!
};

It's a great addition for discoverability.

@bluelovers
Copy link
Author

they don't want type for it
#10275

@Timer
Copy link
Member

Timer commented Sep 12, 2020

See #13429

@eps1lon
Copy link
Member

eps1lon commented Sep 12, 2020

See #13429

It doesn't look like that PR adds a public type. It was suggested (#13429 (comment)) but it's not apparent how I would import the config type.

@Rowno
Copy link
Contributor

Rowno commented Sep 27, 2020

Gatsby exposes really good types for their config, which allows you to strongly type the JavaScript config file using JSDoc as described above.

@lfades
Copy link
Member

lfades commented Sep 28, 2020

This is not one of our current priorities but I'm open to review a PR that adds types for Next.js configurations (similar to #13429 which was closed due to being quite outdated)

@vercel vercel locked and limited conversation to collaborators Apr 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants