@@ -20518,18 +20518,21 @@ namespace ts {
20518
20518
function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind {
20519
20519
// Resolve the symbol as a value to ensure the type can be reached at runtime during emit.
20520
20520
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
20521
- const globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol();
20522
- if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
20523
- return TypeReferenceSerializationKind.Promise;
20524
- }
20525
-
20526
- const constructorType = valueSymbol ? getTypeOfSymbol(valueSymbol) : undefined;
20527
- if (constructorType && isConstructorType(constructorType)) {
20528
- return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
20529
- }
20530
20521
20531
20522
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
20532
20523
const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
20524
+ if (valueSymbol && valueSymbol === typeSymbol) {
20525
+ const globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol();
20526
+ if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
20527
+ return TypeReferenceSerializationKind.Promise;
20528
+ }
20529
+
20530
+ const constructorType = getTypeOfSymbol(valueSymbol);
20531
+ if (constructorType && isConstructorType(constructorType)) {
20532
+ return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
20533
+ }
20534
+ }
20535
+
20533
20536
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
20534
20537
if (!typeSymbol) {
20535
20538
return TypeReferenceSerializationKind.ObjectType;
0 commit comments