Skip to content

Commit 25462be

Browse files
Merge pull request #28456 from Microsoft/nonExperimentalBigInt
BigInt shouldn't be considered experimental
2 parents 2b345cc + 624fdcb commit 25462be

File tree

30 files changed

+115
-88
lines changed

30 files changed

+115
-88
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30642,13 +30642,10 @@ namespace ts {
3064230642
isPrefixUnaryExpression(node.parent) && isLiteralTypeNode(node.parent.parent);
3064330643
if (!literalType) {
3064430644
if (languageVersion < ScriptTarget.ESNext) {
30645-
if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targetting_lower_than_ESNext)) {
30645+
if (grammarErrorOnNode(node, Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ESNext)) {
3064630646
return true;
3064730647
}
3064830648
}
30649-
if (!compilerOptions.experimentalBigInt) {
30650-
return grammarErrorOnNode(node, Diagnostics.Experimental_support_for_BigInt_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalBigInt_option_to_remove_this_warning);
30651-
}
3065230649
}
3065330650
return false;
3065430651
}

src/compiler/commandLineParser.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,6 @@ namespace ts {
584584
category: Diagnostics.Experimental_Options,
585585
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
586586
},
587-
{
588-
name: "experimentalBigInt",
589-
type: "boolean",
590-
category: Diagnostics.Experimental_Options,
591-
description: Diagnostics.Enables_experimental_support_for_ESNext_BigInt_literals
592-
},
593587

594588
// Advanced
595589
{

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,10 +1011,6 @@
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-
},
10181014

10191015
"Duplicate identifier '{0}'.": {
10201016
"category": "Error",
@@ -2505,7 +2501,7 @@
25052501
"category": "Error",
25062502
"code": 2736
25072503
},
2508-
"BigInt literals are not available when targetting lower than ESNext.": {
2504+
"BigInt literals are not available when targeting lower than ESNext.": {
25092505
"category": "Error",
25102506
"code": 2737
25112507
},
@@ -3933,10 +3929,6 @@
39333929
"category": "Error",
39343930
"code": 6370
39353931
},
3936-
"Enables experimental support for ESNext BigInt literals.": {
3937-
"category": "Message",
3938-
"code": 6371
3939-
},
39403932

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

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4495,7 +4495,6 @@ namespace ts {
44954495
downlevelIteration?: boolean;
44964496
emitBOM?: boolean;
44974497
emitDecoratorMetadata?: boolean;
4498-
experimentalBigInt?: boolean;
44994498
experimentalDecorators?: boolean;
45004499
forceConsistentCasingInFileNames?: boolean;
45014500
/*@internal*/help?: boolean;

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,6 @@ declare namespace ts {
24502450
downlevelIteration?: boolean;
24512451
emitBOM?: boolean;
24522452
emitDecoratorMetadata?: boolean;
2453-
experimentalBigInt?: boolean;
24542453
experimentalDecorators?: boolean;
24552454
forceConsistentCasingInFileNames?: boolean;
24562455
importHelpers?: boolean;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,6 @@ declare namespace ts {
24502450
downlevelIteration?: boolean;
24512451
emitBOM?: boolean;
24522452
emitDecoratorMetadata?: boolean;
2453-
experimentalBigInt?: boolean;
24542453
experimentalDecorators?: boolean;
24552454
forceConsistentCasingInFileNames?: boolean;
24562455
importHelpers?: boolean;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
tests/cases/compiler/bigIntWithTargetES3.ts(5,22): error TS2737: BigInt literals are not available when targeting lower than ESNext.
2+
tests/cases/compiler/bigIntWithTargetES3.ts(5,29): error TS2737: BigInt literals are not available when targeting lower than ESNext.
3+
tests/cases/compiler/bigIntWithTargetES3.ts(5,39): error TS2737: BigInt literals are not available when targeting lower than ESNext.
4+
tests/cases/compiler/bigIntWithTargetES3.ts(5,48): error TS2737: BigInt literals are not available when targeting lower than ESNext.
5+
6+
7+
==== tests/cases/compiler/bigIntWithTargetES3.ts (4 errors) ====
8+
const normalNumber = 123; // should not error
9+
let bigintType: bigint; // should not error
10+
let bigintLiteralType: 123n; // should not error when used as type
11+
let bigintNegativeLiteralType: -123n; // should not error when used as type
12+
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
13+
~~~~
14+
!!! error TS2737: BigInt literals are not available when targeting lower than ESNext.
15+
~~~~~~~
16+
!!! error TS2737: BigInt literals are not available when targeting lower than ESNext.
17+
~~~~~~
18+
!!! error TS2737: BigInt literals are not available when targeting lower than ESNext.
19+
~~~~~
20+
!!! error TS2737: BigInt literals are not available when targeting lower than ESNext.
21+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//// [bigIntWithTargetES3.ts]
2+
const normalNumber = 123; // should not error
3+
let bigintType: bigint; // should not error
4+
let bigintLiteralType: 123n; // should not error when used as type
5+
let bigintNegativeLiteralType: -123n; // should not error when used as type
6+
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
7+
8+
9+
//// [bigIntWithTargetES3.js]
10+
var normalNumber = 123; // should not error
11+
var bigintType; // should not error
12+
var bigintLiteralType; // should not error when used as type
13+
var bigintNegativeLiteralType; // should not error when used as type
14+
var bigintNumber = 123n * 15n + 292n * 0x7fn; // each literal should error
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/compiler/bigIntWithTargetES3.ts ===
2+
const normalNumber = 123; // should not error
3+
>normalNumber : Symbol(normalNumber, Decl(bigIntWithTargetES3.ts, 0, 5))
4+
5+
let bigintType: bigint; // should not error
6+
>bigintType : Symbol(bigintType, Decl(bigIntWithTargetES3.ts, 1, 3))
7+
8+
let bigintLiteralType: 123n; // should not error when used as type
9+
>bigintLiteralType : Symbol(bigintLiteralType, Decl(bigIntWithTargetES3.ts, 2, 3))
10+
11+
let bigintNegativeLiteralType: -123n; // should not error when used as type
12+
>bigintNegativeLiteralType : Symbol(bigintNegativeLiteralType, Decl(bigIntWithTargetES3.ts, 3, 3))
13+
14+
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
15+
>bigintNumber : Symbol(bigintNumber, Decl(bigIntWithTargetES3.ts, 4, 5))
16+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/compiler/bigIntWithTargetES3.ts ===
2+
const normalNumber = 123; // should not error
3+
>normalNumber : 123
4+
>123 : 123
5+
6+
let bigintType: bigint; // should not error
7+
>bigintType : bigint
8+
9+
let bigintLiteralType: 123n; // should not error when used as type
10+
>bigintLiteralType : 123n
11+
12+
let bigintNegativeLiteralType: -123n; // should not error when used as type
13+
>bigintNegativeLiteralType : -123n
14+
>-123n : -123n
15+
>123n : 123n
16+
17+
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
18+
>bigintNumber : bigint
19+
>123n * 0b1111n + 0o444n * 0x7fn : bigint
20+
>123n * 0b1111n : bigint
21+
>123n : 123n
22+
>0b1111n : 15n
23+
>0o444n * 0x7fn : bigint
24+
>0o444n : 292n
25+
>0x7fn : 127n
26+

0 commit comments

Comments
 (0)