diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3201434da5..3e60239561 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2408,7 +2408,16 @@ module ts { function getTypeOfAlias(symbol: Symbol): Type { let links = getSymbolLinks(symbol); if (!links.type) { - links.type = getTypeOfSymbol(resolveAlias(symbol)); + let targetSymbol = resolveAlias(symbol); + + // It only makes sense to get the type of a value symbol. If the result of resolving + // the alias is not a value, then it has no type. To get the type associated with a + // type symbol, call getDeclaredTypeOfSymbol. + // This check is important because without it, a call to getTypeOfSymbol could end + // up recursively calling getTypeOfAlias, causing a stack overflow. + links.type = targetSymbol.flags & SymbolFlags.Value + ? getTypeOfSymbol(targetSymbol) + : unknownType; } return links.type; } diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index 1ab6e31cdb..d11c5e639e 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -35,9 +35,9 @@ class FourSlashRunner extends RunnerBase { this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false }); } - describe(this.testSuiteName, () => { this.tests.forEach((fn: string) => { - fn = ts.normalizeSlashes(fn); + describe(fn, () => { + fn = ts.normalizeSlashes(fn); var justName = fn.replace(/^.*[\\\/]/, ''); // Convert to relative path diff --git a/tests/cases/fourslash/aliasMergingWithNamespace.ts b/tests/cases/fourslash/aliasMergingWithNamespace.ts new file mode 100644 index 0000000000..66ab97890c --- /dev/null +++ b/tests/cases/fourslash/aliasMergingWithNamespace.ts @@ -0,0 +1,9 @@ +/// + +////namespace bar { } +////import bar = bar/**/; + +goTo.marker(); +verify.quickInfoIs( +`namespace bar +import bar = bar`); \ No newline at end of file