From 26f73d4dc89191fdc317f9e359a5035761413495 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Thu, 14 May 2015 13:20:09 -0700 Subject: [PATCH] Add a comment in getTypeOfAlias --- src/compiler/checker.ts | 6 ++++++ 1 file changed, 6 insertions(+) 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;