@@ -245,6 +245,9 @@ namespace ts.formatting {
245245 public NoSpaceAfterTypeAssertion : Rule ;
246246 public SpaceAfterTypeAssertion : Rule ;
247247
248+ // No space before non-null assertion operator
249+ public NoSpaceBeforeNonNullAssertionOperator : Rule ;
250+
248251 constructor ( ) {
249252 ///
250253 /// Common Rules
@@ -410,6 +413,9 @@ namespace ts.formatting {
410413 this . NoSpaceBeforeEqualInJsxAttribute = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . EqualsToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsJsxAttributeContext , Rules . IsNonJsxSameLineTokenContext ) , RuleAction . Delete ) ) ;
411414 this . NoSpaceAfterEqualInJsxAttribute = new Rule ( RuleDescriptor . create3 ( SyntaxKind . EqualsToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsJsxAttributeContext , Rules . IsNonJsxSameLineTokenContext ) , RuleAction . Delete ) ) ;
412415
416+ // No space before non-null assertion operator
417+ this . NoSpaceBeforeNonNullAssertionOperator = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . ExclamationToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . IsNonNullAssertionContext ) , RuleAction . Delete ) ) ;
418+
413419 // These rules are higher in priority than user-configurable rules.
414420 this . HighPriorityCommonRules = [
415421 this . IgnoreBeforeComment , this . IgnoreAfterLineComment ,
@@ -456,6 +462,7 @@ namespace ts.formatting {
456462 this . SpaceBeforeAt ,
457463 this . NoSpaceAfterAt ,
458464 this . SpaceAfterDecorator ,
465+ this . NoSpaceBeforeNonNullAssertionOperator
459466 ] ;
460467
461468 // These rules are lower in priority than user-configurable rules.
@@ -882,5 +889,9 @@ namespace ts.formatting {
882889 static IsYieldOrYieldStarWithOperand ( context : FormattingContext ) : boolean {
883890 return context . contextNode . kind === SyntaxKind . YieldExpression && ( < YieldExpression > context . contextNode ) . expression !== undefined ;
884891 }
892+
893+ static IsNonNullAssertionContext ( context : FormattingContext ) : boolean {
894+ return context . contextNode . kind === SyntaxKind . NonNullExpression ;
895+ }
885896 }
886897}
0 commit comments