From 9256e119c660e3de267d7b8a5352bc10d9a1d575 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 17 Dec 2021 15:45:27 -0800 Subject: [PATCH] Check for undefined globalObjectType in getPropertyOfObjectType This can happen during symbol merging when initialising the checker, because global types aren't set until after symbols are merged. May stop the crashes in #47179, #47181, #47180. Does not address the underlying problem of needing to resolve aliases, and therefore names, during symbol merging when initialising the checker. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae7b16234fe..d5a52db2a62 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12360,7 +12360,7 @@ namespace ts { return symbol; } } - return getPropertyOfObjectType(globalObjectType, name); + return globalObjectType === undefined ? undefined : getPropertyOfObjectType(globalObjectType, name); } if (type.flags & TypeFlags.UnionOrIntersection) { return getPropertyOfUnionOrIntersectionType(type as UnionOrIntersectionType, name, skipObjectFunctionPropertyAugment);