Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Declaration Map #218

Closed
Zamiell opened this issue Aug 10, 2022 · 8 comments
Closed

Generate Declaration Map #218

Zamiell opened this issue Aug 10, 2022 · 8 comments

Comments

@Zamiell
Copy link

Zamiell commented Aug 10, 2022

Greetings and thanks for the free tool.

I have a library written in TypeScript. It is consumed by users via npm (like you would expect).

In my library, I include both the source and the compiled output, along with the declaration map. That way, end-users can press F12 on the library functions to very-easily see what the resulting source code looks like. It's really good UX/DX!

Furthermore, the library has some internal functions that shouldn't be put into the auto-complete of end-users. Right now, I just have a crapload of @internal JSDoc comments, but this is pretty terrible. Thus, I would love to use the dts-bundle-generator tool to automatically purge any non-publically-exported functions from the generated .d.ts file. However, I can't do that without also breaking the declaration maps, because dts-bundle-generator does not seem to generate any declaration maps!

Thus, I am stuck and can't use dts-bundle-generator at all. Please consider adding this feature, as I think my use-case is fairly ordinary, all things considered.

@timocov
Copy link
Owner

timocov commented Aug 13, 2022

Looks like it is a duplicate of #179. @Zamiell can you post your comment there please?

@timocov timocov closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2022
@Zamiell
Copy link
Author

Zamiell commented Aug 13, 2022

A declaration map is different from a source map, so it is not the same.

@timocov
Copy link
Owner

timocov commented Aug 13, 2022

Hm, can you elaborate what's the difference please?

@Zamiell
Copy link
Author

Zamiell commented Aug 13, 2022

Source maps are "foo.js.map" files, and declaration maps are "foo.d.ts.map" files. They serve very different purposes.

@timocov
Copy link
Owner

timocov commented Aug 13, 2022

I mean, apart from that a source map is applied to the source code but the declaration map is applied to declaration files?

@Zamiell
Copy link
Author

Zamiell commented Aug 13, 2022

  • Source maps are used by debuggers to generate relevant stack traces at runtime, have TS breakpoints, and so on.
  • Declaration maps are simply used by VSCode to map a .d.ts definition to the real source code, so that end-users can press F12 on constants and functions like in the explanation given in the OP.

@Zamiell
Copy link
Author

Zamiell commented Aug 13, 2022

Furthermore, these are handled by entirely separate compiler flags, such that you can turn on the following combinations:

  • No source maps and no declaration maps
  • Source maps but no declaration maps
  • Declaration maps but no source maps
  • Both source maps and declaration maps

@timocov
Copy link
Owner

timocov commented Aug 13, 2022

Ok I got you. Since we are here talking about the tool that works with declaration files only I thought that I was clear enough that "source maps for declaration files" means "declaration maps", but it seems it is not. I'll rename that ticket because it meant exactly what you're saying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants