我有一个带有 Lerna
的 mono-rep 结构,用于 2 个 NextJS 项目和 1 个共享项目。
最近我尝试启用typescript。 NextJS 项目似乎工作正常(遵循他们的文档),但另一个项目在编译时抛出了问题。
软件包版本:
"next": "^12.0.1",
"typescript": "^4.6.2"
TypeScript 配置 (tsconfig.json
):
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": false,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": false,
"outDir": "dist",
"allowJs": true,
"baseUrl": ".",
"incremental": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"dist",
"jest.*.js",
]
}
错误:
../../node_modules/next/types/index.d.ts:203:5
error TS2386: Overload signatures must all be optional or required.
203:5 randomUUID?(): string
最佳答案
看起来这个问题将在基于 this PR 的 next.js 版本 12.1.1 中得到修复.
目前,您可以 1) 将 typescript 回滚到 4.5.5,2) 升级到 next.js 的 12.1.1-canary 版本,或者 3) 打开 skipLibCheck正如 jsejcksn 所提到的和 salar-hafezi .
关于typescript - NextJS TypeScript 问题 : randomUUID? ():字符串 - 错误 TS2386:重载签名必须全部是可选或必需的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71361915/