Option 'noEmit' cannot be specified with option 'incremental'

后端 未结 2 1848
慢半拍i
慢半拍i 2021-02-19 20:38

I am developing a next.js app. It has the following tsconfig.js

{
  \"compilerOptions\": {
    \"target\": \"ES2018\",
    \"module\": \"esnext\",
          


        
2条回答
  •  清歌不尽
    2021-02-19 20:48

    TS 4.0+

    --incremental with --noEmit is possible now:

    "compilerOptions": {
      "noEmit": true,
      "incremental": true,
      // "tsBuildInfoFile": "/tmp/my-proj/tsbuildinfo" // custom build info file path
      // ...
    }
    

    The build info file is emitted even with noEmit. You can set its explicit location via --tsBuildInfoFile. Otherwise outDir - if still set - or tsconfig.json project root is taken as emit directory.

    Older versions (workaround)

      "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"
      }
    

    More info

    • Allow noEmit and composite together in 3.7 #33809
    • .tsbuildinfo file should be created when the noEmit flag is enabled #30661

提交回复
热议问题