@@ -488,14 +488,16 @@ namespace ts.formatting {
488488 // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
489489 case SyntaxKind . OpenBraceToken :
490490 case SyntaxKind . CloseBraceToken :
491- case SyntaxKind . OpenBracketToken :
492- case SyntaxKind . CloseBracketToken :
493491 case SyntaxKind . OpenParenToken :
494492 case SyntaxKind . CloseParenToken :
495493 case SyntaxKind . ElseKeyword :
496494 case SyntaxKind . WhileKeyword :
497495 case SyntaxKind . AtToken :
498496 return indentation ;
497+ case SyntaxKind . OpenBracketToken :
498+ case SyntaxKind . CloseBracketToken :
499+ return ( container . kind === SyntaxKind . MappedType ) ?
500+ indentation + getEffectiveDelta ( delta , container ) : indentation ;
499501 default :
500502 // if token line equals to the line of containing node (this is a first token in the node) - use node indentation
501503 return nodeStartLine !== line ? indentation + getEffectiveDelta ( delta , container ) : indentation ;
@@ -566,7 +568,7 @@ namespace ts.formatting {
566568 if ( tokenInfo . token . end > node . end ) {
567569 break ;
568570 }
569- consumeTokenAndAdvanceScanner ( tokenInfo , node , nodeDynamicIndentation ) ;
571+ consumeTokenAndAdvanceScanner ( tokenInfo , node , nodeDynamicIndentation , node ) ;
570572 }
571573
572574 function processChildNode (
@@ -617,7 +619,7 @@ namespace ts.formatting {
617619 break ;
618620 }
619621
620- consumeTokenAndAdvanceScanner ( tokenInfo , node , parentDynamicIndentation ) ;
622+ consumeTokenAndAdvanceScanner ( tokenInfo , node , parentDynamicIndentation , node ) ;
621623 }
622624
623625 if ( ! formattingScanner . isOnToken ( ) ) {
@@ -673,11 +675,11 @@ namespace ts.formatting {
673675 computeIndentation ( tokenInfo . token , startLine , Constants . Unknown , parent , parentDynamicIndentation , parentStartLine ) ;
674676
675677 listDynamicIndentation = getDynamicIndentation ( parent , parentStartLine , indentation . indentation , indentation . delta ) ;
676- consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation ) ;
678+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation , parent ) ;
677679 }
678680 else {
679681 // consume any tokens that precede the list as child elements of 'node' using its indentation scope
680- consumeTokenAndAdvanceScanner ( tokenInfo , parent , parentDynamicIndentation ) ;
682+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , parentDynamicIndentation , parent ) ;
681683 }
682684 }
683685 }
@@ -697,13 +699,13 @@ namespace ts.formatting {
697699 // without this check close paren will be interpreted as list end token for function expression which is wrong
698700 if ( tokenInfo . token . kind === listEndToken && rangeContainsRange ( parent , tokenInfo . token ) ) {
699701 // consume list end token
700- consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation ) ;
702+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation , parent ) ;
701703 }
702704 }
703705 }
704706 }
705707
706- function consumeTokenAndAdvanceScanner ( currentTokenInfo : TokenInfo , parent : Node , dynamicIndentation : DynamicIndentation , container ? : Node ) : void {
708+ function consumeTokenAndAdvanceScanner ( currentTokenInfo : TokenInfo , parent : Node , dynamicIndentation : DynamicIndentation , container : Node ) : void {
707709 Debug . assert ( rangeContainsRange ( parent , currentTokenInfo . token ) ) ;
708710
709711 const lastTriviaWasNewLine = formattingScanner . lastTrailingTriviaWasNewLine ( ) ;
0 commit comments