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

.d.ts source map allowing go to def to jump to source directly #14479

Closed
svenefftinge opened this issue Mar 6, 2017 · 12 comments

Comments

@svenefftinge
Copy link

commented Mar 6, 2017

I know it has been asked and discussed before, but I couldn't find an explanation why you recommend to export only the type definitions when publishing an npm package.

As a consumer of an npm package it is quite annoying to end up in d.ts files when browsing code. Especially because I have to switch to the generate, down-leveled JS code to read the actual implementation. It is not only much less readable but also no longer well supported by my editor (no types).

I understand that the tsconfig is important and that one doesn't want to recompile typescript code from npm packages, but the tools should really show the original source instead of the generated code.

I am working on a monorepo project with a bunch of local npm packages with references. We use synthetic links (learna) and in package.jsonwe point to src/index.ts instead of the usual lib/index.d.ts. As a result I can nicely navigate between the local packages and never end up in generated files. With vscode that is, not so much with webstorm...
So at least in our context it seem to be an improvement.

Could you explain what problems this could cause and why you generally seem to recommend not to it like this?

@svenefftinge

This comment has been minimized.

Copy link
Author

commented Mar 6, 2017

See also #12358 (comment)

@ORESoftware

This comment has been minimized.

Copy link

commented Mar 6, 2017

My guess is that if you don't use .d.ts then the typings won't necessarily follow your .js source, which means IDE support will not be there when your codebase integrates with other codebases.

that's my guess as a TS user, but I am not certain.

@mhegazy mhegazy added the Suggestion label Mar 6, 2017
@mhegazy

This comment has been minimized.

Copy link

commented Mar 6, 2017

We have discussed an option of a .d.ts source map that allows editors and other tools to go to the implementation if one is available.

@basarat

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2017

@svenefftinge this covers my reasons : #12358 (comment)

old code, new compiler and outDir getting messed up are the big ones 🌹

@calebboyd

This comment has been minimized.

Copy link

commented Apr 28, 2017

@mhegazy This idea of navigate to source is very interesting / appealing. Is this being tracked anywhere?

@mhegazy

This comment has been minimized.

Copy link

commented Apr 28, 2017

@mhegazy This idea of navigate to source is very interesting / appealing. Is this being tracked anywhere?

I am assuming this issue is tracking that.

@calebboyd

This comment has been minimized.

Copy link

commented Apr 29, 2017

Haha, Alright. :) I was just curious with respect to your note

We have discussed an option...

@mhegazy mhegazy changed the title Why recommendation to publish *.d.ts instead of original source .d.ts source map allowing go to def to jump to source directly Apr 29, 2017
@mhegazy

This comment has been minimized.

Copy link

commented Apr 29, 2017

Clarifying the title for better tracking.

@mariusGundersen

This comment has been minimized.

Copy link

commented Jul 31, 2017

Any status on this?

I guess this would be implemented as two separate tasks:

  • Make typescript output a .d.ts and a .d.ts.map file
  • Make the TypeScript language server use the .d.ts.map file to find which file to load when ctrl+clicking
@mmc41

This comment has been minimized.

Copy link

commented Aug 10, 2017

@mhegazy Any updates on this? - Single most wanted feature for me.

@sinapis

This comment has been minimized.

Copy link

commented Sep 18, 2017

This could solve a problem I'm currently facing. In our project we are using a stricter compilation options for Typescript, but some of the npm modules we use publish the Typescript source code, yet they are not as strict as we are. Which results in a compilation errors when we build our project.

Having a d.ts sourcemap will also provide a solution for people with big repository that they wish to continuously migrate to stricter Typescript - They could create sourcemap to old Typescript and compile only the d.ts, which skips strict checks, while having a base with stricter checks that they can continuously enlarge.

@sinapis

This comment has been minimized.

Copy link

commented Sep 18, 2017

I think this would solve some pain points listed in #9448

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.