indent inside mapped type
This commit is contained in:
parent
bc59d6242b
commit
f4c33aaec4
|
@ -488,14 +488,16 @@ namespace ts.formatting {
|
|||
// open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.CloseBracketToken:
|
||||
case SyntaxKind.OpenParenToken:
|
||||
case SyntaxKind.CloseParenToken:
|
||||
case SyntaxKind.ElseKeyword:
|
||||
case SyntaxKind.WhileKeyword:
|
||||
case SyntaxKind.AtToken:
|
||||
return indentation;
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.CloseBracketToken:
|
||||
return (container.kind === SyntaxKind.MappedType) ?
|
||||
indentation + getEffectiveDelta(delta, container) : indentation;
|
||||
default:
|
||||
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation
|
||||
return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation;
|
||||
|
|
|
@ -438,6 +438,7 @@ namespace ts.formatting {
|
|||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.MappedType:
|
||||
case SyntaxKind.TupleType:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.DefaultClause:
|
||||
|
|
12
tests/cases/fourslash/formattingMappedType.ts
Normal file
12
tests/cases/fourslash/formattingMappedType.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
/////*generic*/type t < T > = {
|
||||
/////*map*/ [ P in keyof T ] : T [ P ]
|
||||
////};
|
||||
|
||||
|
||||
format.document();
|
||||
goTo.marker("generic");
|
||||
verify.currentLineContentIs("type t<T> = {");
|
||||
goTo.marker("map");
|
||||
verify.currentLineContentIs(" [P in keyof T]: T[P]");
|
Loading…
Reference in a new issue