mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 02:18:37 -05:00
Added explicit check for scientific notation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;`
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user