Skip to content

Commit be97d03

Browse files
committed
union type rules
1 parent a74ca18 commit be97d03

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/services/formatting/rules.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ namespace ts.formatting {
223223
public SpaceBetweenTagAndTemplateString: Rule;
224224
public NoSpaceBetweenTagAndTemplateString: Rule;
225225

226+
// Union type
227+
public SpaceBeforeBar: Rule;
228+
public NoSpaceBeforeBar: Rule;
229+
public SpaceAfterBar: Rule;
230+
public NoSpaceAfterBar: Rule;
231+
226232
constructor() {
227233
///
228234
/// Common Rules
@@ -380,6 +386,12 @@ namespace ts.formatting {
380386
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
381387
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
382388

389+
// union type
390+
this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
391+
this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
392+
this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
393+
this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
394+
383395

384396
// These rules are higher in priority than user-configurable rules.
385397
this.HighPriorityCommonRules =
@@ -407,12 +419,10 @@ namespace ts.formatting {
407419
this.NoSpaceBeforeOpenParenInFuncCall,
408420
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
409421
this.SpaceAfterVoidOperator,
410-
this.SpaceAfterAwaitKeyword,
411-
this.NoSpaceAfterAwaitKeyword,
412-
this.SpaceBetweenAsyncAndFunctionKeyword,
413-
this.NoSpaceBetweenAsyncAndFunctionKeyword,
414-
this.SpaceBetweenTagAndTemplateString,
415-
this.NoSpaceBetweenTagAndTemplateString,
422+
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
423+
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
424+
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
425+
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
416426

417427
// TypeScript-specific rules
418428
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,

0 commit comments

Comments
 (0)