diff --git a/integration/before-after-request-streaming/google/protobuf/wrappers.ts b/integration/before-after-request-streaming/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/before-after-request-streaming/google/protobuf/wrappers.ts +++ b/integration/before-after-request-streaming/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/bytes-node/google/protobuf/wrappers.ts b/integration/bytes-node/google/protobuf/wrappers.ts index 4f87f7983..e9d5e91b4 100644 --- a/integration/bytes-node/google/protobuf/wrappers.ts +++ b/integration/bytes-node/google/protobuf/wrappers.ts @@ -634,6 +634,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/emit-default-values-json/google/protobuf/timestamp.ts b/integration/emit-default-values-json/google/protobuf/timestamp.ts index 8b52fafe9..43b0a86f8 100644 --- a/integration/emit-default-values-json/google/protobuf/timestamp.ts +++ b/integration/emit-default-values-json/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/emit-default-values-json/test.ts b/integration/emit-default-values-json/test.ts index 7228938e5..ea2aab3a4 100644 --- a/integration/emit-default-values-json/test.ts +++ b/integration/emit-default-values-json/test.ts @@ -754,6 +754,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/fieldoption-jstype-with-forcelong-bigint/fieldoption-jstype-with-forcelong-bigint.ts b/integration/fieldoption-jstype-with-forcelong-bigint/fieldoption-jstype-with-forcelong-bigint.ts index b2f152b83..8ead513d0 100644 --- a/integration/fieldoption-jstype-with-forcelong-bigint/fieldoption-jstype-with-forcelong-bigint.ts +++ b/integration/fieldoption-jstype-with-forcelong-bigint/fieldoption-jstype-with-forcelong-bigint.ts @@ -127,6 +127,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/fieldoption-jstype-with-forcelong-long/fieldoption-jstype-with-forcelong-long.ts b/integration/fieldoption-jstype-with-forcelong-long/fieldoption-jstype-with-forcelong-long.ts index 45eee1cc7..4a95db0ad 100644 --- a/integration/fieldoption-jstype-with-forcelong-long/fieldoption-jstype-with-forcelong-long.ts +++ b/integration/fieldoption-jstype-with-forcelong-long/fieldoption-jstype-with-forcelong-long.ts @@ -120,6 +120,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/fieldoption-jstype-with-forcelong-number/fieldoption-jstype-with-forcelong-number.ts b/integration/fieldoption-jstype-with-forcelong-number/fieldoption-jstype-with-forcelong-number.ts index 7d2d080f7..73a40dd80 100644 --- a/integration/fieldoption-jstype-with-forcelong-number/fieldoption-jstype-with-forcelong-number.ts +++ b/integration/fieldoption-jstype-with-forcelong-number/fieldoption-jstype-with-forcelong-number.ts @@ -118,6 +118,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/fieldoption-jstype-with-forcelong-string/fieldoption-jstype-with-forcelong-string.ts b/integration/fieldoption-jstype-with-forcelong-string/fieldoption-jstype-with-forcelong-string.ts index 53ee01a6d..b4192cf84 100644 --- a/integration/fieldoption-jstype-with-forcelong-string/fieldoption-jstype-with-forcelong-string.ts +++ b/integration/fieldoption-jstype-with-forcelong-string/fieldoption-jstype-with-forcelong-string.ts @@ -118,6 +118,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/fieldoption-jstype/fieldoption-jstype.ts b/integration/fieldoption-jstype/fieldoption-jstype.ts index 9daccd4ce..4ab4c922b 100644 --- a/integration/fieldoption-jstype/fieldoption-jstype.ts +++ b/integration/fieldoption-jstype/fieldoption-jstype.ts @@ -498,6 +498,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/file-suffix/google/protobuf/timestamp.pb.ts b/integration/file-suffix/google/protobuf/timestamp.pb.ts index 150d84f33..213644e5c 100644 --- a/integration/file-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/file-suffix/google/protobuf/timestamp.pb.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-false/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-js-use-date-string-nano/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-string-nano/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/grpc-js-use-date-string-nano/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-string-nano/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-string/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts b/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts +++ b/integration/grpc-js-use-date-true/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-js/google/protobuf/timestamp.ts b/integration/grpc-js/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/grpc-js/google/protobuf/timestamp.ts +++ b/integration/grpc-js/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-js/google/protobuf/wrappers.ts b/integration/grpc-js/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/grpc-js/google/protobuf/wrappers.ts +++ b/integration/grpc-js/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/grpc-web/google/protobuf/wrappers.ts b/integration/grpc-web/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/grpc-web/google/protobuf/wrappers.ts +++ b/integration/grpc-web/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/import-mapping/google/protobuf/timestamp.ts b/integration/import-mapping/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/import-mapping/google/protobuf/timestamp.ts +++ b/integration/import-mapping/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/import-suffix/google/protobuf/timestamp.pb.ts b/integration/import-suffix/google/protobuf/timestamp.pb.ts index 0bc22a518..2ece1aaf2 100644 --- a/integration/import-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/import-suffix/google/protobuf/timestamp.pb.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/map-long-optional/test.ts b/integration/map-long-optional/test.ts index ead0bf04d..8d97e3b87 100644 --- a/integration/map-long-optional/test.ts +++ b/integration/map-long-optional/test.ts @@ -243,6 +243,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/meta-typings/google/protobuf/timestamp.ts b/integration/meta-typings/google/protobuf/timestamp.ts index f0abd8f16..7235095aa 100644 --- a/integration/meta-typings/google/protobuf/timestamp.ts +++ b/integration/meta-typings/google/protobuf/timestamp.ts @@ -285,6 +285,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/meta-typings/google/protobuf/wrappers.ts b/integration/meta-typings/google/protobuf/wrappers.ts index 47ab03de0..c889c51d6 100644 --- a/integration/meta-typings/google/protobuf/wrappers.ts +++ b/integration/meta-typings/google/protobuf/wrappers.ts @@ -824,6 +824,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/meta-typings/simple.ts b/integration/meta-typings/simple.ts index 3d20affc2..ec8833230 100644 --- a/integration/meta-typings/simple.ts +++ b/integration/meta-typings/simple.ts @@ -2969,6 +2969,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/nice-grpc/google/protobuf/timestamp.ts b/integration/nice-grpc/google/protobuf/timestamp.ts index 62599cfa5..1bc99b3c2 100644 --- a/integration/nice-grpc/google/protobuf/timestamp.ts +++ b/integration/nice-grpc/google/protobuf/timestamp.ts @@ -200,6 +200,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/nice-grpc/google/protobuf/wrappers.ts b/integration/nice-grpc/google/protobuf/wrappers.ts index f947bfa2d..8237f7bd8 100644 --- a/integration/nice-grpc/google/protobuf/wrappers.ts +++ b/integration/nice-grpc/google/protobuf/wrappers.ts @@ -647,6 +647,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/options/google/protobuf/descriptor.ts b/integration/options/google/protobuf/descriptor.ts index 659a41d14..afea9d648 100644 --- a/integration/options/google/protobuf/descriptor.ts +++ b/integration/options/google/protobuf/descriptor.ts @@ -5881,6 +5881,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/output-decode-only/google/protobuf/wrappers.ts b/integration/output-decode-only/google/protobuf/wrappers.ts index e440a56e4..64284eb13 100644 --- a/integration/output-decode-only/google/protobuf/wrappers.ts +++ b/integration/output-decode-only/google/protobuf/wrappers.ts @@ -362,6 +362,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/proto2-no-default-vals/simple.ts b/integration/proto2-no-default-vals/simple.ts index 0af1a7dbe..63d046846 100644 --- a/integration/proto2-no-default-vals/simple.ts +++ b/integration/proto2-no-default-vals/simple.ts @@ -1015,6 +1015,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/proto2-no-optionals/simple.ts b/integration/proto2-no-optionals/simple.ts index cce545031..da688eecb 100644 --- a/integration/proto2-no-optionals/simple.ts +++ b/integration/proto2-no-optionals/simple.ts @@ -1019,6 +1019,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/proto2/simple.ts b/integration/proto2/simple.ts index 48ca11fe9..0e74b0049 100644 --- a/integration/proto2/simple.ts +++ b/integration/proto2/simple.ts @@ -1019,6 +1019,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-esmodule-interop/simple.ts b/integration/simple-esmodule-interop/simple.ts index 979b9cf64..a85a82883 100644 --- a/integration/simple-esmodule-interop/simple.ts +++ b/integration/simple-esmodule-interop/simple.ts @@ -354,6 +354,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-json-name/google/protobuf/timestamp.ts b/integration/simple-json-name/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/simple-json-name/google/protobuf/timestamp.ts +++ b/integration/simple-json-name/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-long/simple.ts b/integration/simple-long/simple.ts index 3e64ca9ae..d4b96a157 100644 --- a/integration/simple-long/simple.ts +++ b/integration/simple-long/simple.ts @@ -860,6 +860,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-optionals/google/protobuf/timestamp.ts b/integration/simple-optionals/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/simple-optionals/google/protobuf/timestamp.ts +++ b/integration/simple-optionals/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-optionals/google/protobuf/wrappers.ts b/integration/simple-optionals/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/simple-optionals/google/protobuf/wrappers.ts +++ b/integration/simple-optionals/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-optionals/simple.ts b/integration/simple-optionals/simple.ts index 2c0d94e3a..6ea0ccc95 100644 --- a/integration/simple-optionals/simple.ts +++ b/integration/simple-optionals/simple.ts @@ -1983,6 +1983,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts index d7dcadacd..8f98441db 100644 --- a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts +++ b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts index f0601fcea..9abbd0dd4 100644 --- a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts +++ b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-prototype-defaults/simple.ts b/integration/simple-prototype-defaults/simple.ts index 0e3fbe31b..fe51f20c5 100644 --- a/integration/simple-prototype-defaults/simple.ts +++ b/integration/simple-prototype-defaults/simple.ts @@ -2978,6 +2978,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-snake/google/protobuf/timestamp.ts b/integration/simple-snake/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/simple-snake/google/protobuf/timestamp.ts +++ b/integration/simple-snake/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-snake/google/protobuf/wrappers.ts b/integration/simple-snake/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/simple-snake/google/protobuf/wrappers.ts +++ b/integration/simple-snake/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-snake/simple.ts b/integration/simple-snake/simple.ts index 719bd2800..754e54948 100644 --- a/integration/simple-snake/simple.ts +++ b/integration/simple-snake/simple.ts @@ -2045,6 +2045,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple-unrecognized-enum/simple.ts b/integration/simple-unrecognized-enum/simple.ts index 4747ba475..5823ef1f1 100644 --- a/integration/simple-unrecognized-enum/simple.ts +++ b/integration/simple-unrecognized-enum/simple.ts @@ -1971,6 +1971,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple/google/protobuf/timestamp.ts b/integration/simple/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/simple/google/protobuf/timestamp.ts +++ b/integration/simple/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple/google/protobuf/wrappers.ts b/integration/simple/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/simple/google/protobuf/wrappers.ts +++ b/integration/simple/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/simple/simple.ts b/integration/simple/simple.ts index 957d00ab2..34d78bff5 100644 --- a/integration/simple/simple.ts +++ b/integration/simple/simple.ts @@ -3100,6 +3100,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/static-only-type-registry/google/protobuf/timestamp.ts b/integration/static-only-type-registry/google/protobuf/timestamp.ts index 6a9471ac8..efb98dff1 100644 --- a/integration/static-only-type-registry/google/protobuf/timestamp.ts +++ b/integration/static-only-type-registry/google/protobuf/timestamp.ts @@ -209,6 +209,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/static-only/google/protobuf/timestamp.ts b/integration/static-only/google/protobuf/timestamp.ts index f058013a6..88bfe7b91 100644 --- a/integration/static-only/google/protobuf/timestamp.ts +++ b/integration/static-only/google/protobuf/timestamp.ts @@ -206,6 +206,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/type-annotations/google/protobuf/timestamp.ts b/integration/type-annotations/google/protobuf/timestamp.ts index 91118336d..792cd5f0c 100644 --- a/integration/type-annotations/google/protobuf/timestamp.ts +++ b/integration/type-annotations/google/protobuf/timestamp.ts @@ -208,6 +208,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index 824026942..cd565a1b9 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -211,6 +211,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/unknown-fields/google/protobuf/compiler/plugin.ts b/integration/unknown-fields/google/protobuf/compiler/plugin.ts index e450011d4..86cc49cd0 100644 --- a/integration/unknown-fields/google/protobuf/compiler/plugin.ts +++ b/integration/unknown-fields/google/protobuf/compiler/plugin.ts @@ -511,6 +511,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/unknown-fields/google/protobuf/descriptor.ts b/integration/unknown-fields/google/protobuf/descriptor.ts index 719a457bf..da3087b43 100644 --- a/integration/unknown-fields/google/protobuf/descriptor.ts +++ b/integration/unknown-fields/google/protobuf/descriptor.ts @@ -3721,6 +3721,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-date-false/google/protobuf/timestamp.ts b/integration/use-date-false/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/use-date-false/google/protobuf/timestamp.ts +++ b/integration/use-date-false/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-date-string/google/protobuf/timestamp.ts b/integration/use-date-string/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/use-date-string/google/protobuf/timestamp.ts +++ b/integration/use-date-string/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-date-true/google/protobuf/timestamp.ts b/integration/use-date-true/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/use-date-true/google/protobuf/timestamp.ts +++ b/integration/use-date-true/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-json-name/google/protobuf/timestamp.ts b/integration/use-json-name/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/use-json-name/google/protobuf/timestamp.ts +++ b/integration/use-json-name/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-json-timestamp-raw/google/protobuf/timestamp.ts b/integration/use-json-timestamp-raw/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/use-json-timestamp-raw/google/protobuf/timestamp.ts +++ b/integration/use-json-timestamp-raw/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-map-type/google/protobuf/timestamp.ts b/integration/use-map-type/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/use-map-type/google/protobuf/timestamp.ts +++ b/integration/use-map-type/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-map-type/use-map-type.ts b/integration/use-map-type/use-map-type.ts index 718fc25c1..10309208d 100644 --- a/integration/use-map-type/use-map-type.ts +++ b/integration/use-map-type/use-map-type.ts @@ -775,6 +775,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-optionals-all/google/protobuf/timestamp.ts b/integration/use-optionals-all/google/protobuf/timestamp.ts index 4608ed247..51487760e 100644 --- a/integration/use-optionals-all/google/protobuf/timestamp.ts +++ b/integration/use-optionals-all/google/protobuf/timestamp.ts @@ -206,6 +206,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-optionals-all/test.ts b/integration/use-optionals-all/test.ts index 09106efa1..3e16061c7 100644 --- a/integration/use-optionals-all/test.ts +++ b/integration/use-optionals-all/test.ts @@ -784,6 +784,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-optionals-deprecated-only/test.ts b/integration/use-optionals-deprecated-only/test.ts index 52c573ab8..83ea52045 100644 --- a/integration/use-optionals-deprecated-only/test.ts +++ b/integration/use-optionals-deprecated-only/test.ts @@ -659,6 +659,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/use-optionals-no-undefined/test.ts b/integration/use-optionals-no-undefined/test.ts index 110ee73ef..495acb0c7 100644 --- a/integration/use-optionals-no-undefined/test.ts +++ b/integration/use-optionals-no-undefined/test.ts @@ -763,6 +763,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/value/google/protobuf/wrappers.ts b/integration/value/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/value/google/protobuf/wrappers.ts +++ b/integration/value/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/vector-tile/vector_tile.ts b/integration/vector-tile/vector_tile.ts index 7d46fd60f..3654ada86 100644 --- a/integration/vector-tile/vector_tile.ts +++ b/integration/vector-tile/vector_tile.ts @@ -570,6 +570,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/wrappers-regression/google/protobuf/timestamp.ts b/integration/wrappers-regression/google/protobuf/timestamp.ts index 150d84f33..213644e5c 100644 --- a/integration/wrappers-regression/google/protobuf/timestamp.ts +++ b/integration/wrappers-regression/google/protobuf/timestamp.ts @@ -204,6 +204,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/integration/wrappers-regression/google/protobuf/wrappers.ts b/integration/wrappers-regression/google/protobuf/wrappers.ts index f7516ba9a..ba81a4ce9 100644 --- a/integration/wrappers-regression/google/protobuf/wrappers.ts +++ b/integration/wrappers-regression/google/protobuf/wrappers.ts @@ -651,6 +651,9 @@ function longToNumber(long: Long): number { if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } + if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) { + throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); + } return long.toNumber(); } diff --git a/src/main.ts b/src/main.ts index 4198072ba..8870fc33c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -497,7 +497,6 @@ function makeLongUtils(options: Options, bytes: ReturnType `, ); - // TODO This is unused? const numberToLong = conditionalOutput( "numberToLong", code` @@ -532,6 +531,9 @@ function makeLongUtils(options: Options, bytes: ReturnType if (long.gt(${bytes.globalThis}.Number.MAX_SAFE_INTEGER)) { throw new ${bytes.globalThis}.Error("Value is larger than Number.MAX_SAFE_INTEGER") } + if (long.lt(${bytes.globalThis}.Number.MIN_SAFE_INTEGER)) { + throw new ${bytes.globalThis}.Error("Value is smaller than Number.MIN_SAFE_INTEGER") + } return long.toNumber(); } `,