Postgres.js type error string/date

I'm running the following where clause in a select query:
.where(
and(
gt(
sql`${e.originalStartTime} + (${p.endTime} - ${p.startTime})::interval`,
${endingAfter},
),
lt(e.originalStartTime, ${startingBefore),
),
)
.where(
and(
gt(
sql`${e.originalStartTime} + (${p.endTime} - ${p.startTime})::interval`,
${endingAfter},
),
lt(e.originalStartTime, ${startingBefore),
),
)
When printing out the query with parameters, the value for endingAfter is a Date, and has not been turned into a string:
[
2024-01-01T00:00:00Z // endingAfter
'2024-12-31T00:00:00Z' // startingBefore works fine
]
[
2024-01-01T00:00:00Z // endingAfter
'2024-12-31T00:00:00Z' // startingBefore works fine
]
...with the error:
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date
This works fine when I perform .toISOString() on endingAfter, but it doesn't seem to do that automatically in this case, I assume because it doesn't have the column information because the first arguments is an SQL<unknown>. I've tried various things to get this right; using a type parameter for the sql, using .mapWith() with a timestamp column, but haven't managed to come up with the correct magic. I've noted the postgres-js breaking changes in 0.3 around strings/Dates, which is why I have just used .toISOString() for now, but this feels like it should work because it works in the other examples where there is column information present Thanks!