选项'noEmit'不能与选项'incremental'一起指定 [英] Option 'noEmit' cannot be specified with option 'incremental'
问题描述
我正在开发next.js应用程序.它具有以下tsconfig.js
I am developing a next.js app. It has the following tsconfig.js
{
"compilerOptions": {
"target": "ES2018",
"module": "esnext",
"lib": [
"dom",
"es2018",
"es2019.array"
],
"jsx": "preserve",
"sourceMap": true,
"skipLibCheck": true,
"strict": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"incremental": true
},
"exclude": [
"server",
"next.config.js"
],
"include": [
"lib/global.d.ts",
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.js"
]
}
它在开发模式下运行良好,但是在创建版本时却显示以下错误:
It is running well in the development mode but while creating build it shows following error:
ERROR in tsconfig.json
22:5 Option 'noEmit' cannot be specified with option 'incremental'.
20 | "resolveJsonModule": true,
21 | "isolatedModules": true,
> 22 | "noEmit": true,
| ^
23 | "incremental": true
24 | },
25 | "exclude": [
Next.js 自动在tsconfig.json
文件中注入'noEmit:true'.虽然我确实需要增量模式才能更快地构建.有什么解决方案?
Next.js automatically injects 'noEmit: true' in tsconfig.json
file. While i really need the incremental mode for faster builds. What can be the solution to this?
推荐答案
来自 TypeScript问题#33809 :
将
incremental
和noEmit
放在一起确实没有任何意义,因为noEmit
阻止我们编写增量元数据. (因此,实际上没有什么是增量的.)
It really doesn't make sense to have
incremental
andnoEmit
together, sincenoEmit
prevents us from writing incremental metadata. (So nothing is actually incremental).
如果您实际上只想进行增量检查,则应考虑使用emitDeclarationOnly
而不是noEmit
.
You should consider emitDeclarationOnly
instead of noEmit
, if you actually just want incremental checking.
因此,在定义noEmit: true
时,incremental: true
标志没有做任何事情来加快构建速度.因此,您应该删除noEmit: true
或将其更改为emitDeclarationOnly: true
.
According to this, the incremental: true
flag has done nothing to speed up the build while noEmit: true
is defined. So you should either remove noEmit: true
or change it to emitDeclarationOnly: true
.
您可以使用outDir
和declarationDir
控制输出文件夹.
You can control the output folders using outDir
and declarationDir
.
这篇关于选项'noEmit'不能与选项'incremental'一起指定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!