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

Goto-definition combined with .d.ts.map file produces location past the end of the file #24866

Closed
ghost opened this issue Jun 11, 2018 · 12 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Jun 11, 2018

TypeScript Version: master

Code

See the test "tsserverProjectSystem project references" "goToDefinition" added in #24867.

CC @weswigham

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 11, 2018
@mhegazy mhegazy added this to the TypeScript 3.0 milestone Jun 11, 2018
@weswigham
Copy link
Member

weswigham commented Jun 11, 2018

Is the problem that the generated sourcemaps is wrong or that we are capable of returning a position beyond the file's bounds when an invalid sourcemap is present?

@ghost
Copy link
Author

ghost commented Jun 11, 2018

That's the sourcemap that tsc generated when I tried it out. Would be nice if there were a way to programatically generate a.d.ts and a.d.ts.map inside the test instead of hardcoding.

@weswigham
Copy link
Member

There is! Some of the declaration map tests make use of it.

@weswigham
Copy link
Member

I'm going to hazard a guess that #24886 fixed this.

@ghost
Copy link
Author

ghost commented Jun 15, 2018

Since we're using the feature now, you can reproduce the error by clicking on any skipTrivia in textChanges.ts.

@weswigham
Copy link
Member

I'm going to hazard a guess that #24886 fixed this.

And we haven't done an lkg but only use light to build, so the change can't be seen in our own project yet.

@ghost
Copy link
Author

ghost commented Jun 15, 2018

Hi @weswigham, could you provide the location of the test helper that will generate a map?

@weswigham
Copy link
Member

weswigham commented Jun 15, 2018

@ghost
Copy link
Author

ghost commented Jun 15, 2018

@weswigham Updated #24867 but it looks like the declaration emit hasn't changed in the master branch. Also, while working on that I've noticed that goto-definition doesn't always go to the right file either -- for example, in tsserverProjectSystem.ts, clicking on ProjectService in server.ProjectService takes me to scriptVersionCache.ts instead of editorServices.ts.

@weswigham
Copy link
Member

@andy-ms I'm seeing it go the the right file, but what looks like at least one declaration too far:

less-off

Although what you're seeing is what happens when the language server is vscode's builtin 2.9.1, instead of a more recent build with #24886 in.

@weswigham
Copy link
Member

@andy-ms So it's worth noting that while we "fixed" your test, it's still entirely possible for us to return a position outside the bounds of a file for the end of a span we return (though probably much less likely now, since every identifier is actually sourcemapped). Do we need to guard against that anywhere?

@ghost
Copy link
Author

ghost commented Jun 27, 2018

We do call scriptInfo.positionToLineOffset on the result, but I don't see any asserts in there -- so we'll just return an out-of-bounds location to the editor, which should be able to handle it without crashing.

@mhegazy mhegazy closed this as completed Jun 28, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants