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
Closed

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

svenefftinge opened this issue Mar 6, 2017 · 12 comments
Assignees
Labels
Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@svenefftinge
Copy link

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
Copy link
Author

See also #12358 (comment)

@ORESoftware
Copy link

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 An idea for TypeScript label Mar 6, 2017
@mhegazy
Copy link
Contributor

mhegazy 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
Copy link
Contributor

basarat 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
Copy link

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

@mhegazy
Copy link
Contributor

mhegazy 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
Copy link

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
Copy link
Contributor

mhegazy commented Apr 29, 2017

Clarifying the title for better tracking.

@mariusGundersen
Copy link

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
Copy link

mmc41 commented Aug 10, 2017

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

@Gorthog
Copy link

Gorthog 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.

@Gorthog
Copy link

Gorthog commented Sep 18, 2017

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

@mhegazy mhegazy added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Sep 18, 2017
@weswigham weswigham added this to Not started in Rolling Work Tracking Oct 11, 2017
@weswigham weswigham moved this from Not started to Feature in Rolling Work Tracking Oct 16, 2017
@weswigham weswigham moved this from Feature to In Progress in Rolling Work Tracking Mar 3, 2018
@weswigham weswigham moved this from In Progress to In Review in Rolling Work Tracking Mar 20, 2018
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Mar 28, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 28, 2018
@weswigham weswigham removed this from In Review in Rolling Work Tracking May 4, 2018
@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.
Labels
Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

10 participants