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:
6
main.ts
6
main.ts
@@ -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! });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user