diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cb5bcbf0b7e..7a4ba23ca2a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2415,6 +2415,12 @@ module ts { let links = getSymbolLinks(symbol); if (!links.type) { 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;