@@ -3855,17 +3855,17 @@ namespace ts {
3855
3855
return false;
3856
3856
}
3857
3857
3858
- function isTypeSymbolAccessible(typeSymbol: Symbol, enclosingDeclaration: Node | undefined): boolean {
3859
- const access = isSymbolAccessible (typeSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false);
3858
+ function isTypeSymbolAccessible(typeSymbol: Symbol, enclosingDeclaration: Node | undefined, allowModules: boolean ): boolean {
3859
+ const access = isSymbolAccessibleWorker (typeSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false, allowModules );
3860
3860
return access.accessibility === SymbolAccessibility.Accessible;
3861
3861
}
3862
3862
3863
3863
function isValueSymbolAccessible(typeSymbol: Symbol, enclosingDeclaration: Node | undefined): boolean {
3864
- const access = isSymbolAccessible (typeSymbol, enclosingDeclaration, SymbolFlags.Value, /*shouldComputeAliasesToMakeVisible*/ false);
3864
+ const access = isSymbolAccessibleWorker (typeSymbol, enclosingDeclaration, SymbolFlags.Value, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true );
3865
3865
return access.accessibility === SymbolAccessibility.Accessible;
3866
3866
}
3867
3867
3868
- function isAnySymbolAccessible(symbols: Symbol[] | undefined, enclosingDeclaration: Node | undefined, initialSymbol: Symbol, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult | undefined {
3868
+ function isAnySymbolAccessible(symbols: Symbol[] | undefined, enclosingDeclaration: Node | undefined, initialSymbol: Symbol, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean, allowModules: boolean ): SymbolAccessibilityResult | undefined {
3869
3869
if (!length(symbols)) return;
3870
3870
3871
3871
let hadAccessibleChain: Symbol | undefined;
@@ -3880,7 +3880,7 @@ namespace ts {
3880
3880
return hasAccessibleDeclarations;
3881
3881
}
3882
3882
}
3883
- else {
3883
+ else if (allowModules) {
3884
3884
if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
3885
3885
if (shouldComputeAliasesToMakeVisible) {
3886
3886
earlyModuleBail = true;
@@ -3920,7 +3920,7 @@ namespace ts {
3920
3920
containers = [getSymbolOfNode(firstDecl.parent)];
3921
3921
}
3922
3922
}
3923
- const parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
3923
+ const parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible, allowModules );
3924
3924
if (parentResult) {
3925
3925
return parentResult;
3926
3926
}
@@ -3950,8 +3950,12 @@ namespace ts {
3950
3950
* @param shouldComputeAliasToMakeVisible a boolean value to indicate whether to return aliases to be mark visible in case the symbol is accessible
3951
3951
*/
3952
3952
function isSymbolAccessible(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult {
3953
+ return isSymbolAccessibleWorker(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible, true);
3954
+ }
3955
+
3956
+ function isSymbolAccessibleWorker(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean, allowModules: boolean): SymbolAccessibilityResult {
3953
3957
if (symbol && enclosingDeclaration) {
3954
- const result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
3958
+ const result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible, allowModules );
3955
3959
if (result) {
3956
3960
return result;
3957
3961
}
@@ -4331,7 +4335,7 @@ namespace ts {
4331
4335
return createThis();
4332
4336
}
4333
4337
4334
- if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
4338
+ if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, /*allowModules*/ true ))) {
4335
4339
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
4336
4340
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return createTypeReferenceNode(createIdentifier(""), typeArgumentNodes);
4337
4341
return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes);
@@ -4350,7 +4354,7 @@ namespace ts {
4350
4354
}
4351
4355
if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams &&
4352
4356
type.flags & TypeFlags.TypeParameter &&
4353
- !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
4357
+ !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration, /*allowModules*/ true )) {
4354
4358
const name = typeParameterToName(type, context);
4355
4359
context.approximateLength += idText(name).length;
4356
4360
return createTypeReferenceNode(createIdentifier(idText(name)), /*typeArguments*/ undefined);
@@ -6325,7 +6329,7 @@ namespace ts {
6325
6329
: anyType;
6326
6330
const heritageClauses = [
6327
6331
...!length(baseTypes) ? [] : [createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))],
6328
- ...!length(implementsTypes) ? [] : [createHeritageClause(SyntaxKind.ImplementsKeyword, map(implementsTypes, b => serializeBaseType(b, staticBaseType, localName )))]
6332
+ ...!length(implementsTypes) ? [] : [createHeritageClause(SyntaxKind.ImplementsKeyword, map(implementsTypes, b => serializeImplementedType(b )))]
6329
6333
];
6330
6334
const symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
6331
6335
const publicSymbolProps = filter(symbolProps, s => {
@@ -6838,6 +6842,28 @@ namespace ts {
6838
6842
}
6839
6843
}
6840
6844
6845
+ function serializeImplementedType(t: Type) {
6846
+ let typeArgs: TypeNode[] | undefined;
6847
+ let reference: Expression | undefined;
6848
+ if ((t as TypeReference).target && isTypeSymbolAccessible((t as TypeReference).target.symbol, enclosingDeclaration, /*allowModules*/ false)) {
6849
+ typeArgs = map(getTypeArguments(t as TypeReference), t => typeToTypeNodeHelper(t, context));
6850
+ reference = symbolToExpression((t as TypeReference).target.symbol, context, SymbolFlags.Type);
6851
+ }
6852
+ else if (t.symbol && isTypeSymbolAccessible(t.symbol, enclosingDeclaration, /*allowModules*/ false)) {
6853
+ reference = symbolToExpression(t.symbol, context, SymbolFlags.Type);
6854
+ }
6855
+ if (reference) {
6856
+ return createExpressionWithTypeArguments(typeArgs, reference);
6857
+ }
6858
+ else if (context.tracker.reportInaccessibleBaseType) {
6859
+ context.tracker.reportInaccessibleBaseType();
6860
+ return createExpressionWithTypeArguments(/*typeArgs*/ undefined, symbolToExpression(t.symbol, context, SymbolFlags.Type));
6861
+ }
6862
+ else {
6863
+ Debug.fail("context.tracker missing some error reporting methods");
6864
+ }
6865
+ }
6866
+
6841
6867
function getUnusedName(input: string, symbol?: Symbol): string {
6842
6868
if (symbol) {
6843
6869
if (context.remappedSymbolNames!.has("" + getSymbolId(symbol))) {
@@ -23925,7 +23951,7 @@ namespace ts {
23925
23951
// if jsx emit was not react as there wont be error being emitted
23926
23952
reactSym.isReferenced = SymbolFlags.All;
23927
23953
23928
- // If react symbol is alias, mark it as refereced
23954
+ // If react symbol is alias, mark it as referenced
23929
23955
if (reactSym.flags & SymbolFlags.Alias && !getTypeOnlyAliasDeclaration(reactSym)) {
23930
23956
markAliasSymbolAsReferenced(reactSym);
23931
23957
}
0 commit comments