Merge pull request #3160 from Microsoft/getTypeOfAlias
Only call getTypeOfSymbol recursively if it's a value
This commit is contained in:
commit
79ab85e0eb
|
@ -2414,7 +2414,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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
9
tests/cases/fourslash/aliasMergingWithNamespace.ts
Normal file
9
tests/cases/fourslash/aliasMergingWithNamespace.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
///<reference path="fourslash.ts"/>
|
||||
|
||||
////namespace bar { }
|
||||
////import bar = bar/**/;
|
||||
|
||||
goTo.marker();
|
||||
verify.quickInfoIs(
|
||||
`namespace bar
|
||||
import bar = bar`);
|
Loading…
Reference in a new issue