Skip to content

Commit bf763a1

Browse files
Copilotbcho
andcommitted
Address code review feedback: simplify type guards and use direct toString()
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
1 parent f86f9de commit bf763a1

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

sdks/typescript/src/sqlite.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type {
88
import {
99
isInstant,
1010
instantFromEpochMilliseconds,
11-
instantToDate,
1211
} from "./temporal-types";
1312

1413
export class SqliteConnection implements Queryable {
@@ -178,9 +177,9 @@ function decodeColumnValue<V = any>(
178177
}
179178

180179
function encodeColumnValue(value: any): any {
181-
// Handle Temporal.Instant - convert to ISO string
180+
// Handle Temporal.Instant - use built-in toString() for ISO string
182181
if (isInstant(value)) {
183-
return instantToDate(value).toISOString();
182+
return value.toString();
184183
}
185184
// Handle legacy Date objects
186185
if (value instanceof Date) {

sdks/typescript/src/temporal-types.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ export function instantToEpochMilliseconds(instant: Instant): number {
8585
* @returns True if the value is a Temporal.Instant
8686
*/
8787
export function isInstant(value: unknown): value is Instant {
88-
return (
89-
value !== null &&
90-
typeof value === "object" &&
91-
value instanceof Temporal.Instant
92-
);
88+
return value instanceof Temporal.Instant;
9389
}
9490

9591
/**
@@ -98,9 +94,5 @@ export function isInstant(value: unknown): value is Instant {
9894
* @returns True if the value is a Temporal.Duration
9995
*/
10096
export function isDuration(value: unknown): value is Duration {
101-
return (
102-
value !== null &&
103-
typeof value === "object" &&
104-
value instanceof Temporal.Duration
105-
);
97+
return value instanceof Temporal.Duration;
10698
}

0 commit comments

Comments
 (0)