Added explicit check for scientific notation

This commit is contained in:
Josh Goldberg
2019-09-07 19:41:03 -04:00
parent 99f9719ab3
commit 79e9bb1c8f
2 changed files with 7 additions and 3 deletions

View File

@@ -33689,9 +33689,10 @@ namespace ts {
}
function checkNumericLiteralValueSize(node: NumericLiteral) {
// Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint
// Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1
// Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway
if (node.text.length <= 15 || node.text.indexOf(".") !== -1) {
if (node.numericLiteralFlags & TokenFlags.Scientific || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
return;
}

View File

@@ -18,6 +18,7 @@
////2e52;
////2e53;
////2e54;
////1e00000000010;
verify.codeFix({
description: ts.Diagnostics.Convert_to_a_bigint_numeric_literal.message,
@@ -41,7 +42,8 @@ verify.codeFix({
-0x20000000000001;
2e52;
2e53;
2e54;`
2e54;
1e00000000010;`
});
verify.codeFixAll({
@@ -66,5 +68,6 @@ verify.codeFixAll({
-0x20000000000001n;
2e52;
2e53;
2e54;`
2e54;
1e00000000010;`
});