From 5f5f2f63ba3613021d1d287d14c3f6be0593e171 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 --- .claude/settings.local.json | 4 +++- main.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index e52c49a..dc3909f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -4,7 +4,9 @@ "Bash(git init:*)", "Bash(git add:*)", "Bash(git commit:*)", - "Bash(git remote add:*)" + "Bash(git remote add:*)", + "Bash(npm install:*)", + "Bash(npm run build:*)" ], "deny": [], "ask": [] 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! }); } });