experimentalBigInt compiler flag

This commit is contained in:
Caleb Sander
2018-11-05 11:36:31 -08:00
parent 188c07865a
commit 95c24c6c6a
19 changed files with 69 additions and 0 deletions
+3
View File
@@ -9270,6 +9270,9 @@ namespace ts {
function getNumericLiteralValue(node: NumericLiteral): number | PseudoBigInt {
if (node.numericLiteralFlags & TokenFlags.BigInt) {
if (!compilerOptions.experimentalBigInt) {
error(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);
}
return { negative: false, base10Value: parsePseudoBigInt(node.text) };
}
return +node.text;
+6
View File
@@ -584,6 +584,12 @@ namespace ts {
category: Diagnostics.Experimental_Options,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
},
{
name: "experimentalBigInt",
type: "boolean",
category: Diagnostics.Experimental_Options,
description: Diagnostics.Enables_experimental_support_for_ESNext_BigInt_expressions
},
// Advanced
{
+1
View File
@@ -4499,6 +4499,7 @@ namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalBigInt?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
/*@internal*/help?: boolean;
+1
View File
@@ -2458,6 +2458,7 @@ declare namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalBigInt?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
importHelpers?: boolean;
+1
View File
@@ -2458,6 +2458,7 @@ declare namespace ts {
downlevelIteration?: boolean;
emitBOM?: boolean;
emitDecoratorMetadata?: boolean;
experimentalBigInt?: boolean;
experimentalDecorators?: boolean;
forceConsistentCasingInFileNames?: boolean;
importHelpers?: boolean;
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -56,6 +56,7 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
/* Advanced Options */
"noErrorTruncation": true, /* Do not truncate error messages. */
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -56,6 +56,7 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
},
"files": [
"file0.st",
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -56,5 +56,6 @@
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
// "experimentalBigInt": true, /* Enables experimental support for ESNext BigInt expressions. */
}
}
@@ -0,0 +1,17 @@
tests/cases/compiler/warnExperimentalBigIntLiteral.ts(2,22): error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
tests/cases/compiler/warnExperimentalBigIntLiteral.ts(2,29): error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
tests/cases/compiler/warnExperimentalBigIntLiteral.ts(2,39): error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
tests/cases/compiler/warnExperimentalBigIntLiteral.ts(2,48): error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
==== tests/cases/compiler/warnExperimentalBigIntLiteral.ts (4 errors) ====
const normalNumber = 123; // should not error
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
~~~~
!!! error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
~~~~~~~
!!! error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
~~~~~~
!!! error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
~~~~~
!!! error TS1350: Experimental support for BigInt is a feature that is subject to change in a future release. Set the 'experimentalBigInt' option to remove this warning.
@@ -0,0 +1,7 @@
//// [warnExperimentalBigIntLiteral.ts]
const normalNumber = 123; // should not error
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
//// [warnExperimentalBigIntLiteral.js]
var normalNumber = 123; // should not error
var bigintNumber = 123n * 15n + 292n * 0x7fn; // each literal should error
@@ -0,0 +1,7 @@
=== tests/cases/compiler/warnExperimentalBigIntLiteral.ts ===
const normalNumber = 123; // should not error
>normalNumber : Symbol(normalNumber, Decl(warnExperimentalBigIntLiteral.ts, 0, 5))
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
>bigintNumber : Symbol(bigintNumber, Decl(warnExperimentalBigIntLiteral.ts, 1, 5))
@@ -0,0 +1,15 @@
=== tests/cases/compiler/warnExperimentalBigIntLiteral.ts ===
const normalNumber = 123; // should not error
>normalNumber : 123
>123 : 123
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error
>bigintNumber : bigint
>123n * 0b1111n + 0o444n * 0x7fn : bigint
>123n * 0b1111n : bigint
>123n : 123n
>0b1111n : 15n
>0o444n * 0x7fn : bigint
>0o444n : 292n
>0x7fn : 127n
@@ -0,0 +1,2 @@
const normalNumber = 123; // should not error
const bigintNumber = 123n * 0b1111n + 0o444n * 0x7fn; // each literal should error