Support go-to-definition for imports of arbitrary files by andrewbranch · Pull Request #42539 · microsoft/TypeScript (original) (raw)

Fixes #41861

The first commit adds support for jumping to arbitrary files from import/require module specifiers, whether those are scripts or non-source files like CSS (thanks @DanielRosenwasser for the idea that this should work).

The second commit goes further by allowing us to return a successful response for files that don’t exist. I was curious what would happen, so I removed the host.fileExists check and made sure we don’t try to read a file’s text to convert { position: 0 } to { line: 0, column: 0 }. The result in VS Code was this:

File does not exist, do you want to create it?

Having the quick option to create the file seemed like a win to me; better than doing nothing. But I’m open to debate on whether we want that.

Also, if anyone knows how this will work in Visual Studio or has a quick way to test it, that would be appreciated!