gpt4 book ai didi

typescript - 无法使用选项 'noEmit' 指定选项 'incremental'

转载 作者:行者123 更新时间:2023-12-03 14:27:15 25 4
gpt4 key购买 nike

我正在开发一个 next.js 应用程序。它有以下 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"
]
}


它在开发模式下运行良好,但在创建构建时显示以下错误:
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 中注入(inject) 'noEmit: true'文件。虽然我真的需要增量模式来加快构建速度。有什么办法可以解决这个问题?

最佳答案

TS 4.0+--incremental--noEmit is possible现在:

"compilerOptions": {
"noEmit": true,
"incremental": true,
// "tsBuildInfoFile": "/tmp/my-proj/tsbuildinfo" // custom build info file path
// ...
}
构建信息文件 is emitted即使是 noEmit .您可以通过 --tsBuildInfoFile 设置其显式位置.否则 outDir - 如果仍然设置 - 或 tsconfig.json项目根被视为发射目录。
旧版本(解决方法)
  "compilerOptions": {
"incremental": true,
"declaration": true,
"emitDeclarationOnly": true, // to emit at least something
// "noEmit": true,
// ...

// Either set overall output directory
"outDir": "dist",
// or separate locations for build file and declarations
// "declarationDir": "dist"
// "tsBuildInfoFile": "/tmp/my-proj/tsbuildinfo"
}
更多信息
  • Allow noEmit and composite together in 3.7 #33809
  • .tsbuildinfo file should be created when the noEmit flag is enabled #30661
  • 关于typescript - 无法使用选项 'noEmit' 指定选项 'incremental',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60563961/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com