Skip to content

Commit 26f73d4

Browse files
committed
Add a comment in getTypeOfAlias
1 parent 8922a09 commit 26f73d4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,12 @@ module ts {
24152415
let links = getSymbolLinks(symbol);
24162416
if (!links.type) {
24172417
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.
24182424
links.type = targetSymbol.flags & SymbolFlags.Value
24192425
? getTypeOfSymbol(targetSymbol)
24202426
: unknownType;

0 commit comments

Comments
 (0)