Skip to content

Commit 79ab85e

Browse files
committed
Merge pull request #3160 from Microsoft/getTypeOfAlias
Only call getTypeOfSymbol recursively if it's a value
2 parents a8214ed + 26f73d4 commit 79ab85e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,16 @@ module ts {
24142414
function getTypeOfAlias(symbol: Symbol): Type {
24152415
let links = getSymbolLinks(symbol);
24162416
if (!links.type) {
2417-
links.type = getTypeOfSymbol(resolveAlias(symbol));
2417+
let targetSymbol = resolveAlias(symbol);
2418+
2419+
// It only makes sense to get the type of a value symbol. If the result of resolving
2420+
// the alias is not a value, then it has no type. To get the type associated with a
2421+
// type symbol, call getDeclaredTypeOfSymbol.
2422+
// This check is important because without it, a call to getTypeOfSymbol could end
2423+
// up recursively calling getTypeOfAlias, causing a stack overflow.
2424+
links.type = targetSymbol.flags & SymbolFlags.Value
2425+
? getTypeOfSymbol(targetSymbol)
2426+
: unknownType;
24182427
}
24192428
return links.type;
24202429
}

src/harness/fourslashRunner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class FourSlashRunner extends RunnerBase {
3535
this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false });
3636
}
3737

38-
describe(this.testSuiteName, () => {
3938
this.tests.forEach((fn: string) => {
40-
fn = ts.normalizeSlashes(fn);
39+
describe(fn, () => {
40+
fn = ts.normalizeSlashes(fn);
4141
var justName = fn.replace(/^.*[\\\/]/, '');
4242

4343
// Convert to relative path
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
///<reference path="fourslash.ts"/>
2+
3+
////namespace bar { }
4+
////import bar = bar/**/;
5+
6+
goTo.marker();
7+
verify.quickInfoIs(
8+
`namespace bar
9+
import bar = bar`);

0 commit comments

Comments
 (0)