MetaMask / metamask-module-template

A simple template repository for starting new modules in the latest MetaMask fashion.
27 stars 23 forks source link

Generate source maps for `.d.ts` files #182

Closed mcmire closed 1 year ago

mcmire commented 1 year ago

It is a frustrating experience to want to see the source code of a module that's being imported in one's editor only to be presented with the .d.ts file when the module is Cmd-clicked (or "Go to Definition" is invoked). To fix this, TypeScript needs to be configured to generate source maps alongside .d.ts files.

Examples

I can enable this in the core repo first to see how this would work in practice.

mcmire commented 1 year ago

PR for trying this out in core: https://github.com/MetaMask/core/pull/1161

mcmire commented 1 year ago

Update: It is now possible to jump from a symbol in VSCode to the compiled .js file that holds the implementation for the symbol rather than the type definition file.

However, VSCode has a separate command to achieve this than the "Go to Definition" command that it usually uses when you Cmd-/Ctrl-Click on a symbol. Rather, it's called "Go to Source Definition" instead. You can either call this by opening up the Command Palette and choosing this, or you can get VSCode to use this command by default by going into Settings and checking these two boxes:

Screenshot 2023-06-06 at 9 26 07 PM

Once you do that then everything should just work.