Skip to content

Commit f137c92

Browse files
author
Kanchalai Tanglertsampan
committed
Address PR
1 parent e60e72e commit f137c92

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,9 +1762,9 @@ namespace ts {
17621762
* Check if the given symbol in given enclosing declaration is accessible and mark all associated alias to be visible if requested
17631763
*
17641764
* @param symbol a Symbol to check if accessible
1765-
* @param enclosingDeclaration a Node containing the symbol
1765+
* @param enclosingDeclaration a Node containing reference to the symbol
17661766
* @param meaning a SymbolFlags to check if such meaning of the symbol is accessible
1767-
* @param shouldComputeAliasToMarkVisible a boolean value to indicate whether to return aliases to be mark visible in case the symbol is accessible
1767+
* @param shouldComputeAliasToMakeVisible a boolean value to indicate whether to return aliases to be mark visible in case the symbol is accessible
17681768
*/
17691769
function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult {
17701770
if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) {
@@ -1838,7 +1838,7 @@ namespace ts {
18381838
return isAmbientModule(declaration) || (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>declaration));
18391839
}
18401840

1841-
function hasVisibleDeclarations(symbol: Symbol, shouldComputeAliasToMarkVisible: boolean): SymbolVisibilityResult {
1841+
function hasVisibleDeclarations(symbol: Symbol, shouldComputeAliasToMakeVisible: boolean): SymbolVisibilityResult {
18421842
let aliasesToMakeVisible: AnyImportSyntax[];
18431843
if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) {
18441844
return undefined;
@@ -1854,7 +1854,10 @@ namespace ts {
18541854
if (anyImportSyntax &&
18551855
!(getModifierFlags(anyImportSyntax) & ModifierFlags.Export) && // import clause without export
18561856
isDeclarationVisible(<Declaration>anyImportSyntax.parent)) {
1857-
if (shouldComputeAliasToMarkVisible) {
1857+
// In function "buildTypeDisplay" where we decide whether to write type-alias or serialize types,
1858+
// we want to just check if type- alias is accessible or not but we don't care about emitting those alias at that time
1859+
// since we will do the emitting later in trackSymbol.
1860+
if (shouldComputeAliasToMakeVisible) {
18581861
getNodeLinks(declaration).isVisible = true;
18591862
if (aliasesToMakeVisible) {
18601863
if (!contains(aliasesToMakeVisible, anyImportSyntax)) {
@@ -1898,7 +1901,7 @@ namespace ts {
18981901
const symbol = resolveName(enclosingDeclaration, (<Identifier>firstIdentifier).text, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
18991902

19001903
// Verify if the symbol is accessible
1901-
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMarkVisible*/ true)) || <SymbolVisibilityResult>{
1904+
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || <SymbolVisibilityResult>{
19021905
accessibility: SymbolAccessibility.NotAccessible,
19031906
errorSymbolName: getTextOfNode(firstIdentifier),
19041907
errorNode: firstIdentifier

0 commit comments

Comments
 (0)