I can set inlineSources: true
and the TypeScript compiler will put my TS sources into the sourcesContent
attribute of the source map file. Is there any way to do the same thing with a declaration map file generated by setting declarationMap: true
? I wasn't able to find any indication in Google, GitHub, or StackOverflow that this is possible, but before giving up I figured I'd ask.
Using my test repo (https://github.com/justingrant/ts-lib-repro) I tried:
- Running TSC directly via
npm run tsc
- Bundling with rollup via
npm run build
In both cases I was unable to get sourcesContent
populated in the resulting index.d.ts
file. If you want to try it yourself, feel free to fork my repo!
In case you're wondering why anyone would want to do this, there are many package maintainers who are hesitant to include their TS source files in the NPM distributions. Example: https://twitter.com/andhaveaniceday/status/1643360625677180928?s=20
My understanding is that it's not possible to get declaration maps working without shipping the TS sources in the package in the NPM registry, where "working" means that you can use Go to Implementation on a imported function in VS Code and be navigated to the library's TS sources inside node_modules
. I'd be happy to be proven wrong about this!