diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 363bcd50241..d14efb247e1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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; } diff --git a/tests/cases/fourslash/codeFixUseBigIntLiteral.ts b/tests/cases/fourslash/codeFixUseBigIntLiteral.ts index 089f73cba97..dcdff381af3 100644 --- a/tests/cases/fourslash/codeFixUseBigIntLiteral.ts +++ b/tests/cases/fourslash/codeFixUseBigIntLiteral.ts @@ -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;` });