@@ -64,6 +64,7 @@ namespace ts.SymbolDisplay {
6464 if ( flags & SymbolFlags . SetAccessor ) return ScriptElementKind . memberSetAccessorElement ;
6565 if ( flags & SymbolFlags . Method ) return ScriptElementKind . memberFunctionElement ;
6666 if ( flags & SymbolFlags . Constructor ) return ScriptElementKind . constructorImplementationElement ;
67+ if ( flags & SymbolFlags . Signature ) return ScriptElementKind . indexSignatureElement ;
6768
6869 if ( flags & SymbolFlags . Property ) {
6970 if ( flags & SymbolFlags . Transient && ( symbol as TransientSymbol ) . checkFlags & CheckFlags . Synthetic ) {
@@ -506,19 +507,19 @@ namespace ts.SymbolDisplay {
506507 else {
507508 addPrefixForAnyFunctionOrVar ( symbol , symbolKind ) ;
508509 }
509-
510510 // For properties, variables and local vars: show the type
511511 if ( symbolKind === ScriptElementKind . memberVariableElement ||
512512 symbolKind === ScriptElementKind . memberGetAccessorElement ||
513513 symbolKind === ScriptElementKind . memberSetAccessorElement ||
514514 symbolKind === ScriptElementKind . jsxAttribute ||
515515 symbolFlags & SymbolFlags . Variable ||
516516 symbolKind === ScriptElementKind . localVariableElement ||
517+ symbolKind === ScriptElementKind . indexSignatureElement ||
517518 isThisExpression ) {
518519 displayParts . push ( punctuationPart ( SyntaxKind . ColonToken ) ) ;
519520 displayParts . push ( spacePart ( ) ) ;
520521 // If the type is type parameter, format it specially
521- if ( type . symbol && type . symbol . flags & SymbolFlags . TypeParameter ) {
522+ if ( type . symbol && type . symbol . flags & SymbolFlags . TypeParameter && symbolKind !== ScriptElementKind . indexSignatureElement ) {
522523 const typeParameterParts = mapToDisplayParts ( writer => {
523524 const param = typeChecker . typeParameterToDeclaration ( type as TypeParameter , enclosingDeclaration , symbolDisplayNodeBuilderFlags ) ! ;
524525 getPrinter ( ) . writeNode ( EmitHint . Unspecified , param , getSourceFileOfNode ( getParseTreeNode ( enclosingDeclaration ) ) , writer ) ;
@@ -639,13 +640,38 @@ namespace ts.SymbolDisplay {
639640 }
640641
641642 function addFullSymbolName ( symbolToDisplay : Symbol , enclosingDeclaration ?: Node ) {
643+ let indexInfos ;
644+
642645 if ( alias && symbolToDisplay === symbol ) {
643646 symbolToDisplay = alias ;
644647 }
645- const fullSymbolDisplayParts = symbolToDisplayParts ( typeChecker , symbolToDisplay , enclosingDeclaration || sourceFile , /*meaning*/ undefined ,
646- SymbolFormatFlags . WriteTypeParametersOrArguments | SymbolFormatFlags . UseOnlyExternalAliasing | SymbolFormatFlags . AllowAnyNodeKind ) ;
647- addRange ( displayParts , fullSymbolDisplayParts ) ;
648+ if ( symbolKind === ScriptElementKind . indexSignatureElement ) {
649+ indexInfos = typeChecker . getIndexInfosOfIndexSymbol ( symbolToDisplay ) ;
650+ }
648651
652+ let fullSymbolDisplayParts : SymbolDisplayPart [ ] = [ ] ;
653+ if ( symbolToDisplay . flags & SymbolFlags . Signature && indexInfos ) {
654+ if ( symbolToDisplay . parent ) {
655+ fullSymbolDisplayParts = symbolToDisplayParts ( typeChecker , symbolToDisplay . parent ) ;
656+ }
657+ fullSymbolDisplayParts . push ( punctuationPart ( SyntaxKind . OpenBracketToken ) ) ;
658+ //Needed to handle more than one type of index
659+ indexInfos . forEach ( ( info , i ) => {
660+ //Needed to handle template literals
661+ fullSymbolDisplayParts . push ( ...typeToDisplayParts ( typeChecker , info . keyType ) ) ;
662+ if ( i !== indexInfos . length - 1 ) {
663+ fullSymbolDisplayParts . push ( spacePart ( ) ) ;
664+ fullSymbolDisplayParts . push ( punctuationPart ( SyntaxKind . BarToken ) ) ;
665+ fullSymbolDisplayParts . push ( spacePart ( ) ) ;
666+ }
667+ } ) ;
668+ fullSymbolDisplayParts . push ( punctuationPart ( SyntaxKind . CloseBracketToken ) ) ;
669+ }
670+ else {
671+ fullSymbolDisplayParts = symbolToDisplayParts ( typeChecker , symbolToDisplay , enclosingDeclaration || sourceFile , /*meaning*/ undefined ,
672+ SymbolFormatFlags . WriteTypeParametersOrArguments | SymbolFormatFlags . UseOnlyExternalAliasing | SymbolFormatFlags . AllowAnyNodeKind ) ;
673+ }
674+ addRange ( displayParts , fullSymbolDisplayParts ) ;
649675 if ( symbol . flags & SymbolFlags . Optional ) {
650676 displayParts . push ( punctuationPart ( SyntaxKind . QuestionToken ) ) ;
651677 }
0 commit comments