ts-proto 1.161.0 → 1.161.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +3 -2
- package/package.json +1 -1
package/build/main.js
CHANGED
|
@@ -464,12 +464,13 @@ function makeTimestampMethods(options, longs, bytes) {
|
|
|
464
464
|
const Timestamp = (0, utils_1.impProto)(options, "google/protobuf/timestamp", "Timestamp");
|
|
465
465
|
let seconds = "date.getTime() / 1_000";
|
|
466
466
|
let toNumberCode = "t.seconds";
|
|
467
|
+
const makeToNumberCode = (methodCall) => `t.seconds${options.useOptionals === "all" ? "?" : ""}.${methodCall}`;
|
|
467
468
|
if (options.forceLong === options_1.LongOption.LONG) {
|
|
468
|
-
toNumberCode = "
|
|
469
|
+
toNumberCode = makeToNumberCode("toNumber()");
|
|
469
470
|
seconds = (0, ts_poet_1.code) `${longs.numberToLong}(date.getTime() / 1_000)`;
|
|
470
471
|
}
|
|
471
472
|
else if (options.forceLong === options_1.LongOption.BIGINT) {
|
|
472
|
-
toNumberCode = (0, ts_poet_1.code) `${bytes.globalThis}.Number(
|
|
473
|
+
toNumberCode = (0, ts_poet_1.code) `${bytes.globalThis}.Number(${makeToNumberCode("toString()")})`;
|
|
473
474
|
seconds = (0, ts_poet_1.code) `BigInt(Math.trunc(date.getTime() / 1_000))`;
|
|
474
475
|
}
|
|
475
476
|
else if (options.forceLong === options_1.LongOption.STRING) {
|