javascriptnode.jstypescripttsctsup

How to avoid generating .d.ts.map files when using tsc to generate only declaration files?


I am creating a build with tsup. However, dts option throws many errors. And I also see that in the official tsup documentation it says that typescript declarations generated by any tool other than tsc are not guarenteed to be perfect.

Thus, I am using tsc for type declarations.

I am building my app like this

tsup && tsc -p custom-config.json
// custom-config.json
{
  "compilerOptions": {
    "outDir": "dist",
    "emitDeclarationOnly": true,
    "sourceMap": false,
    ...
  }
}

I want to to avoid generating .d.ts.map.


Solution

  • While searching for answers, I landed up on the official typescript docs.

    I found an option called declarationMap - https://www.typescriptlang.org/tsconfig/#declarationMap

    Replacing sourceMap in the config file with declarationMap: false fixed the issue.

    // custom-config.json
    {
      "compilerOptions": {
        "outDir": "dist",
        "emitDeclarationOnly": true,
        "declarationMap": false,
        ...
      }
    }