diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f1a0d4930..e1f230ce09 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2150,8 +2150,13 @@ namespace ts { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); } else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol) { - const typeArguments = type.aliasTypeArguments; - writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + if (type.flags & TypeFlags.Anonymous || !(flags & TypeFormatFlags.UseTypeAliasValue)) { + const typeArguments = type.aliasTypeArguments; + writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); + } + else { + writeUnionOrIntersectionType(type, nextFlags); + } } else if (type.flags & TypeFlags.UnionOrIntersection) { writeUnionOrIntersectionType(type, nextFlags); diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index ab1ca51825..f519a5881b 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -327,7 +327,7 @@ namespace ts { } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); errorNameNode = undefined; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 50beef52bf..4c4cf52087 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1946,6 +1946,7 @@ namespace ts { UseFullyQualifiedType = 0x00000080, // Write out the fully qualified type name (eg. Module.Type, instead of Type) InFirstTypeArgument = 0x00000100, // Writing first type argument of the instantiated type InTypeAlias = 0x00000200, // Writing type in type alias declaration + UseTypeAliasValue = 0x00000400, // Writing infered type alias as its value. This is used when we emit declaration file } export const enum SymbolFormatFlags {