From 862603b8ca258863775d0ac0031e3250756b2f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 7 Nov 2023 09:35:26 +0100 Subject: [PATCH] Move the fix to `getSymbolIfSameReference` itself --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0bdec5d0cda41..4264a41de7bdc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5665,12 +5665,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (getSymbolIfSameReference(exported, symbol)) { return exported; } - if (symbol.flags & SymbolFlags.TypeAlias && exported.declarations?.find(isTypeAlias)) { - const aliasSymbol = getDeclaredTypeOfTypeAlias(exported).aliasSymbol; - if (aliasSymbol && getSymbolIfSameReference(aliasSymbol, symbol)) { - return exported; - } - } }); } @@ -5678,6 +5672,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { * Checks if two symbols, through aliasing and/or merging, refer to the same thing */ function getSymbolIfSameReference(s1: Symbol, s2: Symbol) { + if (s1.flags & SymbolFlags.TypeAlias && s2.declarations?.find(isTypeAlias)) { + s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2; + } + if (s2.flags & SymbolFlags.TypeAlias && s1.declarations?.find(isTypeAlias)) { + s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1; + } if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { return s1; }