@@ -2066,39 +2066,34 @@ namespace ts {
2066
2066
// up front (for example, during checking) could determine if we need to emit the imports
2067
2067
// and we could then access that data during declaration emit.
2068
2068
writer.trackSymbol(symbol, enclosingDeclaration, meaning);
2069
- function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void {
2070
- function climbSymbol(symbol: Symbol, meaning: SymbolFlags, endOfChain?: boolean): void {
2071
- if (symbol) {
2072
- const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing));
2073
-
2074
- if (!accessibleSymbolChain ||
2075
- needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
2076
-
2077
- // Go up and add our parent.
2078
- climbSymbol(
2079
- getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol),
2080
- getQualifiedLeftMeaning(meaning));
2081
- }
2069
+ function walkSymbol(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): void {
2070
+ const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing));
2082
2071
2083
- if (accessibleSymbolChain) {
2084
- for (const accessibleSymbol of accessibleSymbolChain) {
2085
- appendParentTypeArgumentsAndSymbolName(accessibleSymbol);
2086
- }
2087
- }
2088
- else if (
2089
- // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
2090
- endOfChain ||
2091
- // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
2092
- !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
2093
- // If a parent symbol is an anonymous type, don't write it.
2094
- !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) {
2095
-
2096
- appendParentTypeArgumentsAndSymbolName(symbol);
2097
- }
2072
+ if (!accessibleSymbolChain ||
2073
+ needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
2074
+
2075
+ // Go up and add our parent.
2076
+ const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol);
2077
+ if (parent) {
2078
+ walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false);
2098
2079
}
2099
2080
}
2100
2081
2101
- climbSymbol(symbol, meaning, /*endOfChain*/ true);
2082
+ if (accessibleSymbolChain) {
2083
+ for (const accessibleSymbol of accessibleSymbolChain) {
2084
+ appendParentTypeArgumentsAndSymbolName(accessibleSymbol);
2085
+ }
2086
+ }
2087
+ else if (
2088
+ // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
2089
+ endOfChain ||
2090
+ // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.)
2091
+ !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) &&
2092
+ // If a parent symbol is an anonymous type, don't write it.
2093
+ !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) {
2094
+
2095
+ appendParentTypeArgumentsAndSymbolName(symbol);
2096
+ }
2102
2097
}
2103
2098
2104
2099
// Get qualified name if the symbol is not a type parameter
@@ -2107,7 +2102,7 @@ namespace ts {
2107
2102
const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter;
2108
2103
const typeFormatFlag = TypeFormatFlags.UseFullyQualifiedType & typeFlags;
2109
2104
if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) {
2110
- walkSymbol(symbol, meaning);
2105
+ walkSymbol(symbol, meaning, /*endOfChain*/ true );
2111
2106
}
2112
2107
else {
2113
2108
appendParentTypeArgumentsAndSymbolName(symbol);
0 commit comments