From b9b817092ca62d6d51e4365aa345cc5e0f3ca483 Mon Sep 17 00:00:00 2001 From: Eric Burel Date: Wed, 23 Feb 2022 18:08:59 +0100 Subject: [PATCH] docs: Add information about .d.ts.map TypeScript declaration maps (#566) --- docs/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/README.md b/docs/README.md index 1986f896..80ebe11c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -147,6 +147,16 @@ Note that `--dts` does not resolve external (aka in `node_modules`) types used i The `--dts-only` flag is the equivalent of the `emitDeclarationOnly` option in `tsc`. Using this flag will only emit the declaration file, without the JavaScript files. +#### Generate TypeScript declaration maps (.d.ts.map) + +TypeScript declaration maps are mainly used to quickly jump to type definitions in the context of a monorepo (see [source issue](https://github.com/Microsoft/TypeScript/issues/14479) and [official documentation](https://www.typescriptlang.org/tsconfig/#declarationMap)). + +They should not be included in a published NPM package and should not be confused with sourcemaps. + +[Tsup is not able to generate those files](https://github.com/egoist/tsup/issues/564). Instead, you should use the TypeScript compiler directly, by running the following command after the build is done: `tsc --emitDeclarationOnly --declaration`. + +You can combine this command with Tsup [`onSuccess`](https://tsup.egoist.sh/#onsuccess) callback. + ### Generate sourcemap file ```bash