@@ -2153,6 +2153,11 @@ namespace ts {
2153
2153
return false;
2154
2154
}
2155
2155
2156
+ function isTypeSymbolAccessible(typeSymbol: Symbol, enclosingDeclaration: Node): boolean {
2157
+ const access = isSymbolAccessible(typeSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false);
2158
+ return access.accessibility === SymbolAccessibility.Accessible;
2159
+ }
2160
+
2156
2161
/**
2157
2162
* Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested
2158
2163
*
@@ -2483,8 +2488,7 @@ namespace ts {
2483
2488
// Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter.
2484
2489
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
2485
2490
}
2486
- if (!inTypeAlias && type.aliasSymbol &&
2487
- isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) {
2491
+ if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) {
2488
2492
const name = symbolToTypeReferenceName(type.aliasSymbol);
2489
2493
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
2490
2494
return createTypeReferenceNode(name, typeArgumentNodes);
@@ -3251,7 +3255,7 @@ namespace ts {
3251
3255
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags);
3252
3256
}
3253
3257
else if (!(flags & TypeFormatFlags.InTypeAlias) && type.aliasSymbol &&
3254
- isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible ) {
3258
+ ((flags & TypeFormatFlags.UseAliasDefinedOutsideCurrentScope) || isTypeSymbolAccessible(type.aliasSymbol, enclosingDeclaration)) ) {
3255
3259
const typeArguments = type.aliasTypeArguments;
3256
3260
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, length(typeArguments), nextFlags);
3257
3261
}
0 commit comments