From 949cc88d7507be6e8d1f900e1668320f0975374c Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 28 May 2026 01:01:44 +0200 Subject: [PATCH] fix(codex-audit): narrow content non-null in block-handle + inserter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `npm run check` was reporting 'content is possibly null' errors in both block-handle and block-inserter $effect closures — 6 errors between them. TS doesn't carry the `if (!content) return` narrowing into inner closures, so we re-bind to a const typed `HTMLElement` right after the guard. `npm run check`: 22 → 16 errors. Remaining 10 (drawer command-name / mark string-not-assignable, words.svelte missing 'insert-image' key in the Record, plus 6 pre-existing in src/lib/_demo and others) need a deeper look at the command-name / mark string unions — follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/uix/eidos/components/words/words-block-handle.svelte | 7 +++++-- src/uix/eidos/components/words/words-block-inserter.svelte | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/uix/eidos/components/words/words-block-handle.svelte b/src/uix/eidos/components/words/words-block-handle.svelte index 37b205fb3..1b0f2cf3e 100644 --- a/src/uix/eidos/components/words/words-block-handle.svelte +++ b/src/uix/eidos/components/words/words-block-handle.svelte @@ -154,8 +154,11 @@ } $effect(() => { - const content = document.querySelector('[data-words-content]'); - if (!content) return; + const found = document.querySelector('[data-words-content]'); + if (!found) return; + // Narrowed once at the top; TS doesn't carry the narrowing into + // the closure below, so we re-bind to a non-null `content`. + const content: HTMLElement = found; // Listen at the document level (not on `content`) so the cursor // crossing into the grip — which lives OUTSIDE the content box, diff --git a/src/uix/eidos/components/words/words-block-inserter.svelte b/src/uix/eidos/components/words/words-block-inserter.svelte index 806fa9528..c8a245ae3 100644 --- a/src/uix/eidos/components/words/words-block-inserter.svelte +++ b/src/uix/eidos/components/words/words-block-inserter.svelte @@ -114,8 +114,11 @@ } $effect(() => { - const content = document.querySelector('[data-words-content]'); - if (!content) return; + const found = document.querySelector('[data-words-content]'); + if (!found) return; + // Narrowed once at the top; TS doesn't carry the narrowing into + // the closures below, so we re-bind to a non-null `content`. + const content: HTMLElement = found; // Track movement on the document, not on `content`, so the "+" // button (which lives in the left margin OUTSIDE the content