Fix TypeScript errors and build plugin

- 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 <noreply@anthropic.com>
This commit is contained in:
2025-11-26 10:21:46 +01:00
parent 8a1922e4ac
commit 7152027ee3

View File

@@ -28,14 +28,14 @@ export default class CounterPlugin extends Plugin {
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT); const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
const nodesToReplace: Array<{ node: Node; parent: Node }> = []; const nodesToReplace: Array<{ node: Node; parent: Node }> = [];
let node; let node: Node | null;
while ((node = walker.nextNode())) { while ((node = walker.nextNode()) !== null) {
const text = node.textContent || ''; const text = node.textContent || '';
const lines = text.split('\n'); const lines = text.split('\n');
lines.forEach((line, index) => { lines.forEach((line, index) => {
const match = line.match(counterRegex); const match = line.match(counterRegex);
if (match) { if (match && node) {
nodesToReplace.push({ node, parent: node.parentNode! }); nodesToReplace.push({ node, parent: node.parentNode! });
} }
}); });