From 85913f5869ffa2990b3264a9d19f48b2b13fbb0a Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 7 Sep 2026 07:54:10 +0200 Subject: [PATCH] fix(quotes): guard possibly-undefined itemAt in isQuotePdfStale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deployment was failing at `npm run build` with: quote-pdf-service.ts(487,10): error TS18048: 'itemAt' is possibly 'undefined' `itemAt` comes from `latestItem.items[0]?.updated` (row type `{ updated?: string }`), so it's `string | undefined`, while `pdfAt` was already narrowed to `string` by the earlier `if (!pdfAt)` guard — comparing the two fails under strict mode. Semantically, a quote with no active items left (all moved/removed) has no item timestamp, and that alone shouldn't mark the PDF stale; only the quote-level timestamp decides in that case. Verified with a full `npm run build` (exit 0). --- src/lib/server/quote-pdf-service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/server/quote-pdf-service.ts b/src/lib/server/quote-pdf-service.ts index ee927fd..2b7b8ed 100644 --- a/src/lib/server/quote-pdf-service.ts +++ b/src/lib/server/quote-pdf-service.ts @@ -484,5 +484,9 @@ export async function isQuotePdfStale(quoteId: string): Promise { // matches chronological compare for ISO 8601 with consistent // timezone offsets, which PB always emits (UTC, no fractional // seconds). `String(a) > String(b)` is sufficient. - return itemAt > pdfAt || quoteAt > pdfAt; + // + // `itemAt` is undefined when the quote has no active items left + // (all moved/removed) — that alone doesn't make the PDF stale, so + // only the quote-level timestamp decides in that case. + return (itemAt !== undefined && itemAt > pdfAt) || quoteAt > pdfAt; }