Don't goto aliased symbol with no declarations; and update tests

This commit is contained in:
Andy Hanson 2017-05-12 07:32:00 -07:00
parent d6fa91edcd
commit aaf6b83cb5
6 changed files with 16 additions and 13 deletions

View File

@ -51,7 +51,10 @@ namespace ts.GoToDefinition {
// import {A, B} from "mod";
// to jump to the implementation directly.
if (symbol.flags & SymbolFlags.Alias && shouldSkipAlias(node, symbol.declarations[0])) {
symbol = typeChecker.getAliasedSymbol(symbol);
const aliased = typeChecker.getAliasedSymbol(symbol);
if (aliased.declarations) {
symbol = aliased;
}
}
// Because name in short-hand property assignment has two different meanings: property name and property value,

View File

@ -12,7 +12,7 @@
verify.quickInfoAt("useFoo", "import foo");
verify.goToDefinition({
useFoo: "importFoo",
useFoo: "module",
importFoo: "module"
});
@ -27,6 +27,6 @@ verify.goToDefinition({
verify.quickInfoAt("useBang", "import bang = require(\"jquery\")");
verify.goToDefinition({
useBang: "importBang",
useBang: "module",
importBang: "module"
});

View File

@ -4,7 +4,7 @@
////not read
// @Filename: /a.ts
////import { f } from "foo";
/////**/f();
////import { /*def*/f } from "foo";
/////*use*/f();
verify.goToDefinition("", []);
verify.goToDefinition("use", "def");

View File

@ -8,13 +8,13 @@
// @Filename: foo.d.ts
////declare const /*foo_value_declaration*/foo: number;
////declare module "foo_module" {
//// interface I { x: number; y: number }
//// interface /*foo_type_declaration*/I { x: number; y: number }
//// export = I;
////}
// @Filename: foo_user.ts
///////<reference path="foo.d.ts" />
////import /*foo_type_declaration*/foo = require("foo_module");
////import foo = require("foo_module");
////const x = foo/*foo_value*/;
////const i: foo/*foo_type*/ = { x: 1, y: 2 };
@ -39,13 +39,13 @@ verify.goToDefinitionIs("foo_type_declaration");
// @Filename: bar.d.ts
////declare interface /*bar_type_declaration*/bar { x: number; y: number }
////declare module "bar_module" {
//// const x: number;
//// const /*bar_value_declaration*/x: number;
//// export = x;
////}
// @Filename: bar_user.ts
///////<reference path="bar.d.ts" />
////import /*bar_value_declaration*/bar = require("bar_module");
////import bar = require("bar_module");
////const x = bar/*bar_value*/;
////const i: bar/*bar_type*/ = { x: 1, y: 2 };

View File

@ -3,10 +3,10 @@
// @jsx: preserve
// @Filename: C.tsx
////export default class C {}
////export default class /*def*/C {}
// @Filename: a.tsx
////import /*def*/C from "./C";
////import C from "./C";
////const foo = </*use*/C />;
verify.noErrors();

View File

@ -17,6 +17,6 @@ const [r0, r1, r2] = test.ranges();
verify.singleReferenceGroup('"foo"', [r1]);
goTo.marker("foo");
verify.goToDefinitionIs([]);
verify.goToDefinitionIs("foo");
verify.quickInfoIs("import foo");
verify.singleReferenceGroup("import foo", [r0, r2]);