Skip to content
/ next.js Public
  • Notifications
  • Fork 26k
  • Star 121k
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.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump to bottom

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

Closed
eweilow opened this issue Jul 21, 2019 · 6 comments
Closed

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

eweilow opened this issue Jul 21, 2019 · 6 comments

Comments

@eweilow
Copy link

eweilow commented Jul 21, 2019

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.

@timneutkens
Copy link
Member

timneutkens commented 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.

@timneutkens timneutkens closed this as completed Aug 10, 2019
@evgenymarkov
Copy link

evgenymarkov commented 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

@natemoo-re natemoo-re mentioned this issue Dec 3, 2019
Support ES module format (ESM) in next.config.js #9607
Closed
@zenVentzi
Copy link

zenVentzi commented Mar 19, 2020

Any movement on this?

@eps1lon eps1lon mentioned this issue Apr 12, 2020
[request] better typescript type for next.config.js NextConfig #10254
Closed
@tylerbrostrom
Copy link

tylerbrostrom commented Nov 23, 2020

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

Snowpack鈥檚 official TypeScript templates use @type annotations in this way. Makes for great DX (and could be made better if they were to add annotations).

Implementing a NextConfig type seems like it might be a pain in the butt, especially if it鈥檚 to be integrated into the codebase (as opposed to a third-party Definitely Typed package). Might be more of a maintenance burden than it鈥檚 worth?

@timneutkens would you be open to a PR integrating a NextConfig type? I figured you might have a better idea of how feasible/worthwhile this might be 馃檪 Thanks!

@timneutkens
Copy link
Member

timneutkens commented Nov 24, 2020

@timneutkens would you be open to a PR integrating a NextConfig type? I figured you might have a better idea of how feasible/worthwhile this might be 馃檪 Thanks!

Sure there's already multiple PRs to add such a type but they have not been merged yet given they were incomplete/did not have tests. If you open a new PR we'd be happy to take a look.

@balazsorban44
Copy link
Member

balazsorban44 commented Jan 29, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@eweilow @tylerbrostrom @timneutkens @zenVentzi @evgenymarkov @balazsorban44

Footer

© 2024 GitHub, Inc.

哆哆女性网商业运营公司起名梦参老和尚地藏经讲解文案设计网站鼠年正月女宝宝起名大全笔记本哪个牌子好融资租赁公司起名周公解梦穿新衣服宝宝算命起名寓意好古诗起名字几周容易脐带绕颈北海平原网站建设酷刷平台腊月十八出生的男孩起名高宇桥海子签名理财产品排行付融宝收益高周易取名广告英文名起中文名一切都不会过去湖南卫视金鹰独播剧场养生气功十三势炸串店起名qq如何删除个性签名虐杀原形1起名字大全男孩罗河南虞城卷尺打造超玄幻如何给公司起个好名字制作网站青岛杭州顾家家居淀粉肠小王子日销售额涨超10倍罗斯否认插足凯特王妃婚姻不负春光新的一天从800个哈欠开始有个姐真把千机伞做出来了国产伟哥去年销售近13亿充个话费竟沦为间接洗钱工具重庆警方辟谣“男子杀人焚尸”男子给前妻转账 现任妻子起诉要回春分繁花正当时呼北高速交通事故已致14人死亡杨洋拄拐现身医院月嫂回应掌掴婴儿是在赶虫子男孩疑遭霸凌 家长讨说法被踢出群因自嘲式简历走红的教授更新简介网友建议重庆地铁不准乘客携带菜筐清明节放假3天调休1天郑州一火锅店爆改成麻辣烫店19岁小伙救下5人后溺亡 多方发声两大学生合买彩票中奖一人不认账张家界的山上“长”满了韩国人?单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#青海通报栏杆断裂小学生跌落住进ICU代拍被何赛飞拿着魔杖追着打315晚会后胖东来又人满为患了当地回应沈阳致3死车祸车主疑毒驾武汉大学樱花即将进入盛花期张立群任西安交通大学校长为江西彩礼“减负”的“试婚人”网友洛杉矶偶遇贾玲倪萍分享减重40斤方法男孩8年未见母亲被告知被遗忘小米汽车超级工厂正式揭幕周杰伦一审败诉网易特朗普谈“凯特王妃P图照”考生莫言也上北大硕士复试名单了妈妈回应孩子在校撞护栏坠楼恒大被罚41.75亿到底怎么缴男子持台球杆殴打2名女店员被抓校方回应护栏损坏小学生课间坠楼外国人感慨凌晨的中国很安全火箭最近9战8胜1负王树国3次鞠躬告别西交大师生房客欠租失踪 房东直发愁萧美琴窜访捷克 外交部回应山西省委原副书记商黎光被逮捕阿根廷将发行1万与2万面值的纸币英国王室又一合照被质疑P图男子被猫抓伤后确诊“猫抓病”

哆哆女性网 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化