From d0cc95e8016028b807f62bffdff39a900d177377 Mon Sep 17 00:00:00 2001 From: Cleve Stuart Date: Tue, 29 Aug 2023 08:14:21 -0700 Subject: [PATCH] Accept undefined in setLastTxnTs input but treat it as a no-op. This resolves typescript compilation errors while maintaining current behavior --- package.json | 2 +- src/client.ts | 13 ++++++------- src/util/package-version.ts | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index d5e3b72f..9b453886 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fauna", - "version": "1.0.1", + "version": "1.0.2", "description": "A driver to query Fauna databases in browsers, Node.js, and other Javascript runtimes", "homepage": "https://fauna.com", "bugs": { diff --git a/src/client.ts b/src/client.ts index a87531dd..72bb1c97 100644 --- a/src/client.ts +++ b/src/client.ts @@ -125,20 +125,19 @@ export class Client { /** * @returns the last transaction time seen by this client, or undefined if this client has not seen a transaction time. */ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore it's okay that #lastTxnTs could be undefined on get, but we want - // to enforce that the user never intentionally set it to undefined. get lastTxnTs(): number | undefined { return this.#lastTxnTs; } /** * Sets the last transaction time of this client. * @param ts - the last transaction timestamp to set, as microseconds since - * the epoch. If `ts` is less than the existing `#lastTxnTs` value, then no - * change is made. + * the epoch. If `ts` is less than the existing `#lastTxnTs` value or is + * undefined , then no change is made. */ - set lastTxnTs(ts: number) { - this.#lastTxnTs = this.#lastTxnTs ? Math.max(ts, this.#lastTxnTs) : ts; + set lastTxnTs(ts: number | undefined) { + if (ts !== undefined) { + this.#lastTxnTs = this.#lastTxnTs ? Math.max(ts, this.#lastTxnTs) : ts; + } } /** diff --git a/src/util/package-version.ts b/src/util/package-version.ts index b3bd471e..c28c6101 100644 --- a/src/util/package-version.ts +++ b/src/util/package-version.ts @@ -1,4 +1,4 @@ //THIS FILE IS AUTOGENERATED. DO NOT EDIT. SEE .husky/pre-commit /** The current package version. */ -export const packageVersion = "1.0.1"; +export const packageVersion = "1.0.2";