Skip to content

Commit fd5771a

Browse files
committed
Add diagnostic messages for bigints
1 parent 1db443c commit fd5771a

File tree

67 files changed

+3814
-3802
lines changed

Some content is hidden

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

67 files changed

+3814
-3802
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21464,7 +21464,7 @@ namespace ts {
2146421464
case SyntaxKind.PlusPlusToken:
2146521465
case SyntaxKind.MinusMinusToken:
2146621466
const ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand),
21467-
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type);
21467+
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
2146821468
if (ok) {
2146921469
// run check only if former checks succeeded to avoid reporting cascading errors
2147021470
checkReferenceExpression(node.operand, Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access);
@@ -21482,7 +21482,7 @@ namespace ts {
2148221482
const ok = checkArithmeticOperandType(
2148321483
node.operand,
2148421484
checkNonNullType(operandType, node.operand),
21485-
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type);
21485+
Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type);
2148621486
if (ok) {
2148721487
// run check only if former checks succeeded to avoid reporting cascading errors
2148821488
checkReferenceExpression(node.operand, Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access);
@@ -21882,8 +21882,8 @@ namespace ts {
2188221882
}
2188321883
else {
2188421884
// otherwise just check each operand separately and report errors as normal
21885-
const leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
21886-
const rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
21885+
const leftOk = checkArithmeticOperandType(left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type);
21886+
const rightOk = checkArithmeticOperandType(right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type);
2188721887
if (leftOk && rightOk) {
2188821888
checkAssignmentOperator(numberType);
2188921889
}

src/compiler/diagnosticMessages.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,10 @@
10111011
"category": "Message",
10121012
"code": 1350
10131013
},
1014+
"Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.": {
1015+
"category": "Error",
1016+
"code": 1351
1017+
},
10141018

10151019
"Duplicate identifier '{0}'.": {
10161020
"category": "Error",
@@ -1236,7 +1240,7 @@
12361240
"category": "Error",
12371241
"code": 2355
12381242
},
1239-
"An arithmetic operand must be of type 'any', 'number' or an enum type.": {
1243+
"An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.": {
12401244
"category": "Error",
12411245
"code": 2356
12421246
},
@@ -1260,11 +1264,11 @@
12601264
"category": "Error",
12611265
"code": 2361
12621266
},
1263-
"The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": {
1267+
"The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.": {
12641268
"category": "Error",
12651269
"code": 2362
12661270
},
1267-
"The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": {
1271+
"The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.": {
12681272
"category": "Error",
12691273
"code": 2363
12701274
},
@@ -2493,6 +2497,10 @@
24932497
"category": "Error",
24942498
"code": 2734
24952499
},
2500+
"Operator '{0}' cannot be applied to type '{1}'.": {
2501+
"category": "Error",
2502+
"code": 2735
2503+
},
24962504

24972505
"Import declaration '{0}' is using private name '{1}'.": {
24982506
"category": "Error",
@@ -3893,6 +3901,10 @@
38933901
"category": "Error",
38943902
"code": 6370
38953903
},
3904+
"Enables experimental support for ESNext BigInt expressions.": {
3905+
"category": "Message",
3906+
"code": 6371
3907+
},
38963908

38973909
"The expected type comes from property '{0}' which is declared here on type '{1}'": {
38983910
"category": "Message",

src/testRunner/unittests/tscWatchMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ export default test;`;
12921292
]);
12931293
changeParameterType("y", "string", [
12941294
getDiagnosticOfFileFromProgram(watch(), aFile.path, aFile.content.indexOf("5"), 1, Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1, "5", "string"),
1295-
getDiagnosticOfFileFromProgram(watch(), bFile.path, bFile.content.indexOf("y /"), 1, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)
1295+
getDiagnosticOfFileFromProgram(watch(), bFile.path, bFile.content.indexOf("y /"), 1, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type)
12961296
]);
12971297

12981298
function changeParameterType(parameterName: string, toType: string, expectedErrors: ReadonlyArray<Diagnostic>) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
2-
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
2+
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
33

44

55
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts (2 errors) ====
66
yield * [];
77
~~~~~
88
!!! error TS2304: Cannot find name 'yield'.
99
~~
10-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
10+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
tests/cases/compiler/arithmeticOnInvalidTypes.ts(3,9): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
2-
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
3-
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
4-
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
5-
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
6-
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
7-
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
2+
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
3+
tests/cases/compiler/arithmeticOnInvalidTypes.ts(4,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
4+
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
5+
tests/cases/compiler/arithmeticOnInvalidTypes.ts(5,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
6+
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
7+
tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
88

99

1010
==== tests/cases/compiler/arithmeticOnInvalidTypes.ts (7 errors) ====
@@ -15,16 +15,16 @@ tests/cases/compiler/arithmeticOnInvalidTypes.ts(6,14): error TS2363: The right-
1515
!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
1616
var z2 = x - y;
1717
~
18-
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
18+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
1919
~
20-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
20+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2121
var z3 = x * y;
2222
~
23-
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
23+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2424
~
25-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
25+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2626
var z4 = x / y;
2727
~
28-
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
28+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2929
~
30-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
30+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(2,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
2-
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
3-
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
4-
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
5-
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
6-
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
7-
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
2+
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
3+
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(3,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
4+
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
5+
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(4,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
6+
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,14): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
7+
tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
88

99

1010
==== tests/cases/compiler/arithmeticOnInvalidTypes2.ts (7 errors) ====
@@ -14,18 +14,18 @@ tests/cases/compiler/arithmeticOnInvalidTypes2.ts(5,18): error TS2363: The right
1414
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
1515
var z2 = a - b;
1616
~
17-
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
17+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
1818
~
19-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
19+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2020
var z3 = a * b;
2121
~
22-
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
22+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2323
~
24-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
24+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2525
var z4 = a / b;
2626
~
27-
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
27+
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2828
~
29-
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
29+
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
3030
return a;
3131
};

0 commit comments

Comments
 (0)