docs/libs/typescript.js
function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) {
                var parentSymbol;
                function appendParentTypeArgumentsAndSymbolName(symbol) {
                    if (parentSymbol) {
                        // Write type arguments of instantiated class/interface here
                        if (flags & 1 /* WriteTypeParametersOrArguments */) {
                            if (symbol.flags & 16777216 /* Instantiated */) {
                                buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration);
                            }
                            else {
                                buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration);
                            }
                        }
                        appendPropertyOrElementAccessForSymbol(symbol, writer);
                    }
                    else {
                        appendSymbolNameOnly(symbol, writer);
                    }
                    parentSymbol = symbol;
                }
                // const the writer know we just wrote out a symbol.  The declaration emitter writer uses
                // this to determine if an import it has previously seen (and not written out) needs
                // to be written to the file once the walk of the tree is complete.
                //
                // NOTE(cyrusn): This approach feels somewhat unfortunate.  A simple pass over the tree
                // up front (for example, during checking) could determine if we need to emit the imports
                // and we could then access that data during declaration emit.
                writer.trackSymbol(symbol, enclosingDeclaration, meaning);
                function walkSymbol(symbol, meaning) {
                    if (symbol) {
                        var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */));
                        if (!accessibleSymbolChain ||
                            needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
                            // Go up and add our parent.
                            walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning));
                        }
                        if (accessibleSymbolChain) {
                            for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) {
                                var accessibleSymbol = accessibleSymbolChain_1[_i];
                                appendParentTypeArgumentsAndSymbolName(accessibleSymbol);
                            }
                        }
                        else {
                            // If we didn't find accessible symbol chain for this symbol, break if this is external module
                            if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) {
                                return;
                            }
                            // if this is anonymous type break
                            if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) {
                                return;
                            }
                            appendParentTypeArgumentsAndSymbolName(symbol);
                        }
                    }
                }
                // Get qualified name if the symbol is not a type parameter
                // and there is an enclosing declaration or we specifically
                // asked for it
                var isTypeParameter = symbol.flags & 262144 /* TypeParameter */;
                var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags;
                if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) {
                    walkSymbol(symbol, meaning);
                    return;
                }
                return appendParentTypeArgumentsAndSymbolName(symbol);
            }
function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags, typeFlags) {
                var parentSymbol;
                function appendParentTypeArgumentsAndSymbolName(symbol) {
                    if (parentSymbol) {
                        // Write type arguments of instantiated class/interface here
                        if (flags & 1 /* WriteTypeParametersOrArguments */) {
                            if (symbol.flags & 16777216 /* Instantiated */) {
                                buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration);
                            }
                            else {
                                buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration);
                            }
                        }
                        appendPropertyOrElementAccessForSymbol(symbol, writer);
                    }
                    else {
                        appendSymbolNameOnly(symbol, writer);
                    }
                    parentSymbol = symbol;
                }
                // const the writer know we just wrote out a symbol.  The declaration emitter writer uses
                // this to determine if an import it has previously seen (and not written out) needs
                // to be written to the file once the walk of the tree is complete.
                //
                // NOTE(cyrusn): This approach feels somewhat unfortunate.  A simple pass over the tree
                // up front (for example, during checking) could determine if we need to emit the imports
                // and we could then access that data during declaration emit.
                writer.trackSymbol(symbol, enclosingDeclaration, meaning);
                function walkSymbol(symbol, meaning) {
                    if (symbol) {
                        var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */));
                        if (!accessibleSymbolChain ||
                            needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
                            // Go up and add our parent.
                            walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning));
                        }
                        if (accessibleSymbolChain) {
                            for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) {
                                var accessibleSymbol = accessibleSymbolChain_1[_i];
                                appendParentTypeArgumentsAndSymbolName(accessibleSymbol);
                            }
                        }
                        else {
                            // If we didn't find accessible symbol chain for this symbol, break if this is external module
                            if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) {
                                return;
                            }
                            // if this is anonymous type break
                            if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) {
                                return;
                            }
                            appendParentTypeArgumentsAndSymbolName(symbol);
                        }
                    }
                }
                // Get qualified name if the symbol is not a type parameter
                // and there is an enclosing declaration or we specifically
                // asked for it
                var isTypeParameter = symbol.flags & 262144 /* TypeParameter */;
                var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags;
                if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) {
                    walkSymbol(symbol, meaning);
                    return;
                }
                return appendParentTypeArgumentsAndSymbolName(symbol);
            }
function buildSymbolDisplay ( symbol , writer , enclosingDeclaration , meaning , flags , typeFlags ) { var parentSymbol ; function appendParentTypeArgumentsAndSymbolName ( symbol ) { if ( parentSymbol ) { // Write type arguments of instantiated class/interface here if ( flags & 1 /* WriteTypeParametersOrArguments */ ) { if ( symbol . flags & 16777216 /* Instantiated */ ) { buildDisplayForTypeArgumentsAndDelimiters ( getTypeParametersOfClassOrInterface ( parentSymbol ) , symbol . mapper , writer , enclosingDeclaration ) ; } else { buildTypeParameterDisplayFromSymbol ( parentSymbol , writer , enclosingDeclaration ) ; } } appendPropertyOrElementAccessForSymbol ( symbol , writer ) ; } else { appendSymbolNameOnly ( symbol , writer ) ; } parentSymbol = symbol ; } // const the writer know we just wrote out a symbol.  The declaration emitter writer uses // this to determine if an import it has previously seen (and not written out) needs // to be written to the file once the walk of the tree is complete. // // NOTE(cyrusn): This approach feels somewhat unfortunate.  A simple pass over the tree // up front (for example, during checking) could determine if we need to emit the imports // and we could then access that data during declaration emit. writer . trackSymbol ( symbol , enclosingDeclaration , meaning ) ; function walkSymbol ( symbol , meaning ) { if ( symbol ) { var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaning , ! ! ( flags & 2 /* UseOnlyExternalAliasing */ ) ) ; if ( ! accessibleSymbolChain || needsQualification ( accessibleSymbolChain [ 0 ] , enclosingDeclaration , accessibleSymbolChain . length === 1 ? meaning : getQualifiedLeftMeaning ( meaning ) ) ) { // Go up and add our parent. walkSymbol ( getParentOfSymbol ( accessibleSymbolChain ? accessibleSymbolChain [ 0 ] : symbol ) , getQualifiedLeftMeaning ( meaning ) ) ; } if ( accessibleSymbolChain ) { for ( var _i = 0 , accessibleSymbolChain_1 = accessibleSymbolChain ; _i < accessibleSymbolChain_1 . length ; _i ++ ) { var accessibleSymbol = accessibleSymbolChain_1 [ _i ] ; appendParentTypeArgumentsAndSymbolName ( accessibleSymbol ) ; } } else { // If we didn't find accessible symbol chain for this symbol, break if this is external module if ( ! parentSymbol && ts . forEach ( symbol . declarations , hasExternalModuleSymbol ) ) { return ; } // if this is anonymous type break if ( symbol . flags & 2048 /* TypeLiteral */ || symbol . flags & 4096 /* ObjectLiteral */ ) { return ; } appendParentTypeArgumentsAndSymbolName ( symbol ) ; } } } // Get qualified name if the symbol is not a type parameter // and there is an enclosing declaration or we specifically // asked for it var isTypeParameter = symbol . flags & 262144 /* TypeParameter */ ; var typeFormatFlag = 128 /* UseFullyQualifiedType */ & typeFlags ; if ( ! isTypeParameter && ( enclosingDeclaration || typeFormatFlag ) ) { walkSymbol ( symbol , meaning ) ; return ; } return appendParentTypeArgumentsAndSymbolName ( symbol ) ; }
Enclosing declaration is optional when we don't want to get qualified name in the enclosing declaration scope
Meaning needs to be specified if the enclosing declaration is given
Enclosing declaration is optional when we don t want to get qualified name in the enclosing declaration scope Meaning needs to be specified if the enclosing declaration is given