选项“ noEmit”不能与选项“ incremental”一起指定

TypeScript React.js

古一Green

2020-03-23

我正在开发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自动文件中注入“ noEmit:true”tsconfig.json虽然我确实需要增量模式才能更快地构建。有什么解决方案?

第3038篇《选项“ noEmit”不能与选项“ incremental”一起指定》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
Tony凯 2020.03.23

TypeScript问题#33809开始

这真的没有意义有incrementalnoEmit在一起,因为noEmit阻止我们写增量元数据。(因此,实际上没有什么是增量的)。

如果您实际上只想进行增量检查,则应该考虑使用emitDeclarationOnly而不是noEmit

据此,incremental: true标志在noEmit: true定义时没有采取任何措施来加快构建速度因此,您应该删除noEmit: true它或将其更改为emitDeclarationOnly: true

您可以使用outDir控制输出文件夹declarationDir

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android