@@ -245,6 +245,9 @@ namespace ts.formatting {
245
245
public NoSpaceAfterTypeAssertion : Rule ;
246
246
public SpaceAfterTypeAssertion : Rule ;
247
247
248
+ // No space before non-null assertion operator
249
+ public NoSpaceBeforeNonNullAssertionOperator : Rule ;
250
+
248
251
constructor ( ) {
249
252
///
250
253
/// Common Rules
@@ -410,6 +413,9 @@ namespace ts.formatting {
410
413
this . NoSpaceBeforeEqualInJsxAttribute = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . EqualsToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsJsxAttributeContext , Rules . IsNonJsxSameLineTokenContext ) , RuleAction . Delete ) ) ;
411
414
this . NoSpaceAfterEqualInJsxAttribute = new Rule ( RuleDescriptor . create3 ( SyntaxKind . EqualsToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsJsxAttributeContext , Rules . IsNonJsxSameLineTokenContext ) , RuleAction . Delete ) ) ;
412
415
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
+
413
419
// These rules are higher in priority than user-configurable rules.
414
420
this . HighPriorityCommonRules = [
415
421
this . IgnoreBeforeComment , this . IgnoreAfterLineComment ,
@@ -456,6 +462,7 @@ namespace ts.formatting {
456
462
this . SpaceBeforeAt ,
457
463
this . NoSpaceAfterAt ,
458
464
this . SpaceAfterDecorator ,
465
+ this . NoSpaceBeforeNonNullAssertionOperator
459
466
] ;
460
467
461
468
// These rules are lower in priority than user-configurable rules.
@@ -882,5 +889,9 @@ namespace ts.formatting {
882
889
static IsYieldOrYieldStarWithOperand ( context : FormattingContext ) : boolean {
883
890
return context . contextNode . kind === SyntaxKind . YieldExpression && ( < YieldExpression > context . contextNode ) . expression !== undefined ;
884
891
}
892
+
893
+ static IsNonNullAssertionContext ( context : FormattingContext ) : boolean {
894
+ return context . contextNode . kind === SyntaxKind . NonNullExpression ;
895
+ }
885
896
}
886
897
}
0 commit comments