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