Skip to content

Commit 4e46b97

Browse files
Merge pull request #10877 from RyanCavanaugh/disallowBadCommas
Disallow bad comma left operands
2 parents 5e3e0d6 + 6a89972 commit 4e46b97

File tree

116 files changed

+2104
-618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2104
-618
lines changed

src/compiler/checker.ts

+69
Original file line numberDiff line numberDiff line change
@@ -13265,6 +13265,72 @@ namespace ts {
1326513265
return sourceType;
1326613266
}
1326713267

13268+
/**
13269+
* This is a *shallow* check: An expression is side-effect-free if the
13270+
* evaluation of the expression *itself* cannot produce side effects.
13271+
* For example, x++ / 3 is side-effect free because the / operator
13272+
* does not have side effects.
13273+
* The intent is to "smell test" an expression for correctness in positions where
13274+
* its value is discarded (e.g. the left side of the comma operator).
13275+
*/
13276+
function isSideEffectFree(node: Node): boolean {
13277+
node = skipParentheses(node);
13278+
switch (node.kind) {
13279+
case SyntaxKind.Identifier:
13280+
case SyntaxKind.StringLiteral:
13281+
case SyntaxKind.RegularExpressionLiteral:
13282+
case SyntaxKind.TaggedTemplateExpression:
13283+
case SyntaxKind.TemplateExpression:
13284+
case SyntaxKind.NoSubstitutionTemplateLiteral:
13285+
case SyntaxKind.NumericLiteral:
13286+
case SyntaxKind.TrueKeyword:
13287+
case SyntaxKind.FalseKeyword:
13288+
case SyntaxKind.NullKeyword:
13289+
case SyntaxKind.UndefinedKeyword:
13290+
case SyntaxKind.FunctionExpression:
13291+
case SyntaxKind.ClassExpression:
13292+
case SyntaxKind.ArrowFunction:
13293+
case SyntaxKind.ArrayLiteralExpression:
13294+
case SyntaxKind.ObjectLiteralExpression:
13295+
case SyntaxKind.TypeOfExpression:
13296+
case SyntaxKind.NonNullExpression:
13297+
case SyntaxKind.JsxSelfClosingElement:
13298+
case SyntaxKind.JsxElement:
13299+
return true;
13300+
13301+
case SyntaxKind.ConditionalExpression:
13302+
return isSideEffectFree((node as ConditionalExpression).whenTrue) &&
13303+
isSideEffectFree((node as ConditionalExpression).whenFalse);
13304+
13305+
case SyntaxKind.BinaryExpression:
13306+
if (isAssignmentOperator((node as BinaryExpression).operatorToken.kind)) {
13307+
return false;
13308+
}
13309+
return isSideEffectFree((node as BinaryExpression).left) &&
13310+
isSideEffectFree((node as BinaryExpression).right);
13311+
13312+
case SyntaxKind.PrefixUnaryExpression:
13313+
case SyntaxKind.PostfixUnaryExpression:
13314+
// Unary operators ~, !, +, and - have no side effects.
13315+
// The rest do.
13316+
switch ((node as PrefixUnaryExpression).operator) {
13317+
case SyntaxKind.ExclamationToken:
13318+
case SyntaxKind.PlusToken:
13319+
case SyntaxKind.MinusToken:
13320+
case SyntaxKind.TildeToken:
13321+
return true;
13322+
}
13323+
return false;
13324+
13325+
// Some forms listed here for clarity
13326+
case SyntaxKind.VoidExpression: // Explicit opt-out
13327+
case SyntaxKind.TypeAssertionExpression: // Not SEF, but can produce useful type warnings
13328+
case SyntaxKind.AsExpression: // Not SEF, but can produce useful type warnings
13329+
default:
13330+
return false;
13331+
}
13332+
}
13333+
1326813334
function isTypeEqualityComparableTo(source: Type, target: Type) {
1326913335
return (target.flags & TypeFlags.Nullable) !== 0 || isTypeComparableTo(source, target);
1327013336
}
@@ -13426,6 +13492,9 @@ namespace ts {
1342613492
checkAssignmentOperator(rightType);
1342713493
return getRegularTypeOfObjectLiteral(rightType);
1342813494
case SyntaxKind.CommaToken:
13495+
if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) {
13496+
error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
13497+
}
1342913498
return rightType;
1343013499
}
1343113500

src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,10 @@
19551955
"category": "Error",
19561956
"code": 2694
19571957
},
1958+
"Left side of comma operator is unused and has no side effects.": {
1959+
"category": "Error",
1960+
"code": 2695
1961+
},
19581962

19591963
"Import declaration '{0}' is using private name '{1}'.": {
19601964
"category": "Error",
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,1): error TS2364: Invalid left-hand side of assignment expression.
2+
tests/cases/compiler/assignmentToParenthesizedExpression1.ts(2,2): error TS2695: Left side of comma operator is unused and has no side effects.
23

34

4-
==== tests/cases/compiler/assignmentToParenthesizedExpression1.ts (1 errors) ====
5+
==== tests/cases/compiler/assignmentToParenthesizedExpression1.ts (2 errors) ====
56
var x;
67
(1, x)=0;
78
~~~~~~
8-
!!! error TS2364: Invalid left-hand side of assignment expression.
9+
!!! error TS2364: Invalid left-hand side of assignment expression.
10+
~
11+
!!! error TS2695: Left side of comma operator is unused and has no side effects.

tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.errors.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
2-
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
3-
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
1+
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
2+
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
3+
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(49,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
44

55

66
==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (3 errors) ====
7+
78
// ~ operator on any type
89

910
var ANY: any;

tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithAnyOtherType.ts]
2+
23
// ~ operator on any type
34

45
var ANY: any;

tests/baselines/reference/bitwiseNotOperatorWithBooleanType.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithBooleanType.ts]
2+
23
// ~ operator on boolean type
34
var BOOLEAN: boolean;
45

Original file line numberDiff line numberDiff line change
@@ -1,89 +1,90 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithBooleanType.ts ===
2+
23
// ~ operator on boolean type
34
var BOOLEAN: boolean;
4-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
5+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
56

67
function foo(): boolean { return true; }
7-
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 21))
8+
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 21))
89

910
class A {
10-
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 3, 40))
11+
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 4, 40))
1112

1213
public a: boolean;
13-
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
14+
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
1415

1516
static foo() { return false; }
16-
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 22))
17+
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 7, 22))
1718
}
1819
module M {
19-
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 8, 1))
20+
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 9, 1))
2021

2122
export var n: boolean;
22-
>n : Symbol(n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
23+
>n : Symbol(n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
2324
}
2425

2526
var objA = new A();
26-
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 13, 3))
27-
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 3, 40))
27+
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 14, 3))
28+
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 4, 40))
2829

2930
// boolean type var
3031
var ResultIsNumber1 = ~BOOLEAN;
31-
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithBooleanType.ts, 16, 3))
32-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
32+
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithBooleanType.ts, 17, 3))
33+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
3334

3435
// boolean type literal
3536
var ResultIsNumber2 = ~true;
36-
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithBooleanType.ts, 19, 3))
37+
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 3))
3738

3839
var ResultIsNumber3 = ~{ x: true, y: false };
39-
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 3))
40-
>x : Symbol(x, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 24))
41-
>y : Symbol(y, Decl(bitwiseNotOperatorWithBooleanType.ts, 20, 33))
40+
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithBooleanType.ts, 21, 3))
41+
>x : Symbol(x, Decl(bitwiseNotOperatorWithBooleanType.ts, 21, 24))
42+
>y : Symbol(y, Decl(bitwiseNotOperatorWithBooleanType.ts, 21, 33))
4243

4344
// boolean type expressions
4445
var ResultIsNumber4 = ~objA.a;
45-
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithBooleanType.ts, 23, 3))
46-
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
47-
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 13, 3))
48-
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
46+
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithBooleanType.ts, 24, 3))
47+
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
48+
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 14, 3))
49+
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
4950

5051
var ResultIsNumber5 = ~M.n;
51-
>ResultIsNumber5 : Symbol(ResultIsNumber5, Decl(bitwiseNotOperatorWithBooleanType.ts, 24, 3))
52-
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
53-
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 8, 1))
54-
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
52+
>ResultIsNumber5 : Symbol(ResultIsNumber5, Decl(bitwiseNotOperatorWithBooleanType.ts, 25, 3))
53+
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
54+
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 9, 1))
55+
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
5556

5657
var ResultIsNumber6 = ~foo();
57-
>ResultIsNumber6 : Symbol(ResultIsNumber6, Decl(bitwiseNotOperatorWithBooleanType.ts, 25, 3))
58-
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 21))
58+
>ResultIsNumber6 : Symbol(ResultIsNumber6, Decl(bitwiseNotOperatorWithBooleanType.ts, 26, 3))
59+
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 21))
5960

6061
var ResultIsNumber7 = ~A.foo();
61-
>ResultIsNumber7 : Symbol(ResultIsNumber7, Decl(bitwiseNotOperatorWithBooleanType.ts, 26, 3))
62-
>A.foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 22))
63-
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 3, 40))
64-
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 22))
62+
>ResultIsNumber7 : Symbol(ResultIsNumber7, Decl(bitwiseNotOperatorWithBooleanType.ts, 27, 3))
63+
>A.foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 7, 22))
64+
>A : Symbol(A, Decl(bitwiseNotOperatorWithBooleanType.ts, 4, 40))
65+
>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 7, 22))
6566

6667
// multiple ~ operators
6768
var ResultIsNumber8 = ~~BOOLEAN;
68-
>ResultIsNumber8 : Symbol(ResultIsNumber8, Decl(bitwiseNotOperatorWithBooleanType.ts, 29, 3))
69-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
69+
>ResultIsNumber8 : Symbol(ResultIsNumber8, Decl(bitwiseNotOperatorWithBooleanType.ts, 30, 3))
70+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
7071

7172
// miss assignment operators
7273
~true;
7374
~BOOLEAN;
74-
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 3))
75+
>BOOLEAN : Symbol(BOOLEAN, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 3))
7576

7677
~foo();
77-
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 1, 21))
78+
>foo : Symbol(foo, Decl(bitwiseNotOperatorWithBooleanType.ts, 2, 21))
7879

7980
~true, false;
8081
~objA.a;
81-
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
82-
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 13, 3))
83-
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 5, 9))
82+
>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
83+
>objA : Symbol(objA, Decl(bitwiseNotOperatorWithBooleanType.ts, 14, 3))
84+
>a : Symbol(A.a, Decl(bitwiseNotOperatorWithBooleanType.ts, 6, 9))
8485

8586
~M.n;
86-
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
87-
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 8, 1))
88-
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 10, 14))
87+
>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
88+
>M : Symbol(M, Decl(bitwiseNotOperatorWithBooleanType.ts, 9, 1))
89+
>n : Symbol(M.n, Decl(bitwiseNotOperatorWithBooleanType.ts, 11, 14))
8990

tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithBooleanType.ts ===
2+
23
// ~ operator on boolean type
34
var BOOLEAN: boolean;
45
>BOOLEAN : boolean

tests/baselines/reference/bitwiseNotOperatorWithEnumType.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithEnumType.ts]
2+
23
// ~ operator on enum type
34

45
enum ENUM1 { A, B, "" };
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithEnumType.ts ===
2+
23
// ~ operator on enum type
34

45
enum ENUM1 { A, B, "" };
56
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
6-
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
7-
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
7+
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
8+
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
89

910
// enum type var
1011
var ResultIsNumber1 = ~ENUM1;
11-
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithEnumType.ts, 5, 3))
12+
>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithEnumType.ts, 6, 3))
1213
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
1314

1415
// enum type expressions
1516
var ResultIsNumber2 = ~ENUM1["A"];
16-
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithEnumType.ts, 8, 3))
17+
>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithEnumType.ts, 9, 3))
1718
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
18-
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
19+
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
1920

2021
var ResultIsNumber3 = ~(ENUM1.A + ENUM1["B"]);
21-
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithEnumType.ts, 9, 3))
22-
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
22+
>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithEnumType.ts, 10, 3))
23+
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
2324
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
24-
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
25+
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
2526
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
26-
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
27+
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
2728

2829
// multiple ~ operators
2930
var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B);
30-
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithEnumType.ts, 12, 3))
31+
>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithEnumType.ts, 13, 3))
3132
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
32-
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
33-
>ENUM1.B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
33+
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
34+
>ENUM1.B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
3435
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
35-
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
36+
>B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
3637

3738
// miss assignment operators
3839
~ENUM1;
3940
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
4041

4142
~ENUM1["A"];
4243
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
43-
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
44+
>"A" : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
4445

4546
~ENUM1.A, ~ENUM1["B"];
46-
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
47+
>ENUM1.A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
4748
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
48-
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12))
49+
>A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 12))
4950
>ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0))
50-
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15))
51+
>"B" : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 3, 15))
5152

tests/baselines/reference/bitwiseNotOperatorWithEnumType.types

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithEnumType.ts ===
2+
23
// ~ operator on enum type
34

45
enum ENUM1 { A, B, "" };

tests/baselines/reference/bitwiseNotOperatorWithNumberType.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//// [bitwiseNotOperatorWithNumberType.ts]
2+
23
// ~ operator on number type
34
var NUMBER: number;
45
var NUMBER1: number[] = [1, 2];

0 commit comments

Comments
 (0)