Skip to content

Commit 33534be

Browse files
author
Arnavion
committed
Give MinusToken the same precedence as PlusToken for template expressions.
Fixes microsoft#1577
1 parent 8e2365b commit 33534be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/emitter.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,8 @@ module ts {
21172117
* or equal precedence to the binary '+' operator
21182118
*/
21192119
function comparePrecedenceToBinaryPlus(expression: Expression): Comparison {
2120-
// All binary expressions have lower precedence than '+' apart from '*', '/', and '%'.
2120+
// All binary expressions have lower precedence than '+' apart from '*', '/', and '%'
2121+
// which have greater precedence and '-' which has equal precedence.
21212122
// All unary operators have a higher precedence apart from yield.
21222123
// Arrow functions and conditionals have a lower precedence,
21232124
// although we convert the former into regular function expressions in ES5 mode,
@@ -2134,6 +2135,7 @@ module ts {
21342135
case SyntaxKind.PercentToken:
21352136
return Comparison.GreaterThan;
21362137
case SyntaxKind.PlusToken:
2138+
case SyntaxKind.MinusToken:
21372139
return Comparison.EqualTo;
21382140
default:
21392141
return Comparison.LessThan;

0 commit comments

Comments
 (0)