Support go-to-definition for imports of arbitrary files (#42539)

* Support go-to-definition for imports of scripts and arbitrary files

* Support go-to-definition for non-existent files

* Add missing file property

* Use `isExternalModuleNameRelative` instead of `!pathIsBareSpecifier`

* Add partial semantic test

* Combine with symbol search for non-source-file file references

* Fix and accept API baselines

* Fix useless or

* A definition is unverified if the file path was a guess, even if a source file has that path
This commit is contained in:
Andrew Branch authored and GitHub committed 2021-03-01 15:15:09 -08:00
1 parent aa67b16e99
commit 4b67b4a7bc
15 files changed
+164 -27

No files matched your search

@@ -1,5 +1,5 @@
namespace ts.projectSystem {
describe("unittests:: tsserver:: Semantic operations on PartialSemantic server", () => {
describe("unittests:: tsserver:: Semantic operations on partialSemanticServer", () => {
function setup() {
const file1: File = {
path: `${tscWatch.projectRoot}/a.ts`,
@@ -204,5 +204,20 @@ function fooB() { }`
assert.isUndefined(project.getPackageJsonAutoImportProvider());
assert.deepEqual(project.getPackageJsonsForAutoImport(), emptyArray);
});
it("should support go-to-definition on module specifiers", () => {
const { session, file1, file2 } = setup();
openFilesForSession([file1], session);
const response = session.executeCommandSeq<protocol.DefinitionAndBoundSpanRequest>({
command: protocol.CommandTypes.DefinitionAndBoundSpan,
arguments: protocolFileLocationFromSubstring(file1, `"./b"`)
}).response as protocol.DefinitionInfoAndBoundSpan;
assert.isDefined(response);
assert.deepEqual(response.definitions, [{
file: file2.path,
start: { line: 1, offset: 1 },
end: { line: 1, offset: 1 }
}]);
});
});
}