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.
Files changed (2) hide show
  1. package/build/main.js +3 -2
  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 = "t.seconds.toNumber()";
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(t.seconds.toString())`;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.161.0",
3
+ "version": "1.161.1",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",