Skip to content

Commit

Permalink
Support exponentiation operator in const enums (#20424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy authored Dec 4, 2017
1 parent d814233 commit 37a4056
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 178 deletions.
1 change: 1 addition & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22915,6 +22915,7 @@ namespace ts {
case SyntaxKind.PlusToken: return left + right;
case SyntaxKind.MinusToken: return left - right;
case SyntaxKind.PercentToken: return left % right;
case SyntaxKind.AsteriskAsteriskToken: return left ** right;
}
}
break;
Expand Down
3 changes: 3 additions & 0 deletions tests/baselines/reference/constEnums.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const enum Enum1 {
N = E << 1,
O = E >> B,
P = E >> 1,
PQ = E ** 2,
Q = -D,
R = C & 5,
S = 5 & C,
Expand Down Expand Up @@ -128,6 +129,7 @@ function foo(x: Enum1) {
case Enum1.N:
case Enum1.O:
case Enum1.P:
case Enum1.PQ:
case Enum1.Q:
case Enum1.R:
case Enum1.S:
Expand Down Expand Up @@ -200,6 +202,7 @@ function foo(x) {
case 2 /* N */:
case 0 /* O */:
case 0 /* P */:
case 1 /* PQ */:
case -1 /* Q */:
case 0 /* R */:
case 0 /* S */:
Expand Down
Loading

0 comments on commit 37a4056

Please sign in to comment.