From 7152027ee3989e9f4c1763a7777e806cc48fd9c0 Mon Sep 17 00:00:00 2001 From: Sayuop Date: Wed, 26 Nov 2025 10:21:46 +0100 Subject: [PATCH] Fix TypeScript errors and build plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add proper type annotation for node variable - Add null check in forEach callback - Plugin now builds successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index 5859d50..53c273a 100644 --- a/main.ts +++ b/main.ts @@ -28,14 +28,14 @@ export default class CounterPlugin extends Plugin { const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT); const nodesToReplace: Array<{ node: Node; parent: Node }> = []; - let node; - while ((node = walker.nextNode())) { + let node: Node | null; + while ((node = walker.nextNode()) !== null) { const text = node.textContent || ''; const lines = text.split('\n'); lines.forEach((line, index) => { const match = line.match(counterRegex); - if (match) { + if (match && node) { nodesToReplace.push({ node, parent: node.parentNode! }); } });