Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a50a5d3

Browse filesBrowse files
author
Orta
authored
Merge pull request microsoft#32088 from orta/fix-32068
Handle making sure that two less thans are never converted into >>
2 parents 871bdee + 897fb3a commit a50a5d3
Copy full SHA for a50a5d3

2 files changed

+21Lines changed: 21 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/formatting/rules.ts‎

Copy file name to clipboardExpand all lines: src/services/formatting/rules.ts
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ namespace ts.formatting {
229229

230230
rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, SyntaxKind.ExclamationToken, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], RuleAction.Delete),
231231
rule("NoSpaceAfterNewKeywordOnConstructorSignature", SyntaxKind.NewKeyword, SyntaxKind.OpenParenToken, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], RuleAction.Delete),
232+
rule("SpaceLessThanAndNonJSXTypeAnnotation", SyntaxKind.LessThanToken, SyntaxKind.LessThanToken, [isNonJsxSameLineTokenContext], RuleAction.Space),
232233
];
233234

234235
// These rules are applied after high priority
@@ -349,6 +350,18 @@ namespace ts.formatting {
349350
];
350351
}
351352

353+
/**
354+
* A rule takes a two tokens (left/right) and a particular context
355+
* for which you're meant to look at them. You then declare what should the
356+
* whitespace annotation be between these tokens via the action param.
357+
*
358+
* @param debugName Name to print
359+
* @param left The left side of the comparison
360+
* @param right The right side of the comparison
361+
* @param context A set of filters to narrow down the space in which this formatter rule applies
362+
* @param action a declaration of the expected whitespace
363+
* @param flags whether the rule deletes a line or not, defaults to no-op
364+
*/
352365
function rule(
353366
debugName: string,
354367
left: SyntaxKind | ReadonlyArray<SyntaxKind> | TokenRange,
Collapse file
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
///<reference path="fourslash.ts"/>
2+
// https://github.com/microsoft/TypeScript/issues/14589
3+
4+
/////*1*/if (<number>foo < <number>bar) {}
5+
6+
format.document();
7+
goTo.marker("1")
8+
verify.currentLineContentIs(`if (<number>foo < <number>bar) { }`)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.