【发布时间】:2021-04-11 21:15:39
【问题描述】:
我正在尝试在 NextJS 中使用 TypeScript 创建一个迷你应用程序,因为现在 Next.js 支持 TypeScript。而且我还想合并这两个新添加的功能:
以i18n为例:
// next.config.js
module.exports = {
i18n: {
// These are all the locales you want to support in
// your application
// Sub-path Routing
locales: ['en', 'cn'],
// This is the default locale you want to be used when visiting
// a non-locale prefixed path e.g. `/hello`
defaultLocale: 'en',
},
}
不幸的是,我很难在我的next.config.js 中使用它们,至于普通应用程序(仅限 JavaScript),它可以正常工作。但是对于 TypeScript 版本,我收到了这个错误:
(node:15704) UnhandledPromiseRejectionWarning: TypeError: Cannot set property '__nextLocale' of undefined
如果你们中的任何人能帮助我或者举个例子说明如何正确使用 next.config.js 并将这些新功能整合到 TypeScript NextJS 应用程序中,这将非常有帮助。
【问题讨论】:
标签: typescript next.js nextjs-image