Skip to content

Commit a88366d

Browse files
author
Andy Hanson
committed
Merge branch 'master' into shorthand_ambient_module
2 parents 9fa9710 + 302cea8 commit a88366d

4 files changed

Lines changed: 72 additions & 11 deletions

File tree

src/compiler/checker.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16902,10 +16902,7 @@ namespace ts {
1690216902
return getIntrinsicTagSymbol(<JsxOpeningLikeElement>entityName.parent);
1690316903
}
1690416904

16905-
// Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead
16906-
// return the alias symbol.
16907-
const meaning: SymbolFlags = SymbolFlags.Value | SymbolFlags.Alias;
16908-
return resolveEntityName(<Identifier>entityName, meaning);
16905+
return resolveEntityName(<Identifier>entityName, SymbolFlags.Value, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
1690916906
}
1691016907
else if (entityName.kind === SyntaxKind.PropertyAccessExpression) {
1691116908
const symbol = getNodeLinks(entityName).resolvedSymbol;
@@ -16923,11 +16920,8 @@ namespace ts {
1692316920
}
1692416921
}
1692516922
else if (isTypeReferenceIdentifier(<EntityName>entityName)) {
16926-
let meaning = (entityName.parent.kind === SyntaxKind.TypeReference || entityName.parent.kind === SyntaxKind.JSDocTypeReference) ? SymbolFlags.Type : SymbolFlags.Namespace;
16927-
// Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead
16928-
// return the alias symbol.
16929-
meaning |= SymbolFlags.Alias;
16930-
return resolveEntityName(<EntityName>entityName, meaning);
16923+
const meaning = (entityName.parent.kind === SyntaxKind.TypeReference || entityName.parent.kind === SyntaxKind.JSDocTypeReference) ? SymbolFlags.Type : SymbolFlags.Namespace;
16924+
return resolveEntityName(<EntityName>entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/true);
1693116925
}
1693216926
else if (entityName.parent.kind === SyntaxKind.JsxAttribute) {
1693316927
return getJsxAttributePropertySymbol(<JsxAttribute>entityName.parent);

tests/baselines/reference/typeReferenceDirectives13.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface A {
88

99
x: () => typeof $
1010
>x : Symbol(A.x, Decl(app.ts, 2, 20))
11-
>$ : Symbol($, Decl(app.ts, 1, 8))
11+
>$ : Symbol($, Decl(index.d.ts, 0, 11))
1212
}
1313

1414
=== /ref.d.ts ===

tests/baselines/reference/typeReferenceDirectives5.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface A {
88

99
x: typeof $;
1010
>x : Symbol(A.x, Decl(app.ts, 2, 20))
11-
>$ : Symbol($, Decl(app.ts, 1, 8))
11+
>$ : Symbol($, Decl(index.d.ts, 0, 11))
1212
}
1313
=== /ref.d.ts ===
1414

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
///<reference path="fourslash.ts" />
2+
3+
// Testing that quickInfo gets information with a corresponding meaning: values to values, types to types.
4+
// For quick info purposes, we don't resolve past aliases.
5+
// However, when we have an alias for a type, the quickInfo for a value with the same should skip the alias, and vice versa.
6+
// goToDefinition should work the same way.
7+
8+
// @Filename: foo.d.ts
9+
////declare const /*foo_value_declaration*/foo: number;
10+
////declare module "foo_module" {
11+
//// interface I { x: number; y: number }
12+
//// export = I;
13+
////}
14+
15+
// @Filename: foo_user.ts
16+
///////<reference path="foo.d.ts" />
17+
/////*foo_type_declaration*/import foo = require("foo_module");
18+
////const x = foo/*foo_value*/;
19+
////const i: foo/*foo_type*/ = { x: 1, y: 2 };
20+
21+
verify.numberOfErrorsInCurrentFile(0);
22+
23+
verify.navigationItemsListCount(2, "foo", "exact");
24+
verify.navigationItemsListContains("foo", "alias", "foo", "exact");
25+
verify.navigationItemsListContains("foo", "const", "foo", "exact");
26+
27+
goTo.marker("foo_value");
28+
verify.quickInfoIs("const foo: number");
29+
goTo.definition();
30+
verify.caretAtMarker("foo_value_declaration");
31+
32+
goTo.marker("foo_type");
33+
verify.quickInfoIs("import foo = require(\"foo_module\")");
34+
goTo.definition();
35+
verify.caretAtMarker("foo_type_declaration");
36+
37+
38+
// Above tested for global const and imported interface. Now test with global interface and imported const.
39+
40+
41+
// @Filename: bar.d.ts
42+
/////*bar_type_declaration*/declare interface bar { x: number; y: number }
43+
////declare module "bar_module" {
44+
//// const x: number;
45+
//// export = x;
46+
////}
47+
48+
// @Filename: bar_user.ts
49+
///////<reference path="bar.d.ts" />
50+
/////*bar_value_declaration*/import bar = require("bar_module");
51+
////const x = bar/*bar_value*/;
52+
////const i: bar/*bar_type*/ = { x: 1, y: 2 };
53+
54+
verify.numberOfErrorsInCurrentFile(0);
55+
verify.navigationItemsListCount(2, "bar", "exact");
56+
verify.navigationItemsListContains("bar", "alias", "bar", "exact");
57+
verify.navigationItemsListContains("bar", "interface", "bar", "exact");
58+
59+
goTo.marker("bar_value");
60+
verify.quickInfoIs("import bar = require(\"bar_module\")");
61+
goTo.definition();
62+
verify.caretAtMarker("bar_value_declaration");
63+
64+
goTo.marker("bar_type");
65+
verify.quickInfoIs("interface bar");
66+
goTo.definition();
67+
verify.caretAtMarker("bar_type_declaration");

0 commit comments

Comments
 (0)