Skip to content

Build your personal knowledge base with Trilium Notes

fix(turndown-plugin-gfm): cast ExtendedNode through unknown for input type check

Elian Doran00f6ebd35a13
diff --git a/packages/turndown-plugin-gfm/src/lib/task-list-items.ts b/packages/turndown-plugin-gfm/src/lib/task-list-items.ts
index a1e6fe5843..12b851f9d3 100644
--- a/packages/turndown-plugin-gfm/src/lib/task-list-items.ts
+++ b/packages/turndown-plugin-gfm/src/lib/task-list-items.ts
@@ -3,7 +3,9 @@ import type Turnish from "turnish";
export default function taskListItems (turndownService: Turnish) {
turndownService.addRule('taskListItems', {
filter: function (node) {
- return (node as HTMLInputElement).type === 'checkbox' && node.parentNode?.nodeName === 'LI'
+ // `node` is turnish's ExtendedNode (Element + extra props), which doesn't overlap
+ // HTMLInputElement directly, so cast through `unknown` to read the input `type`.
+ return (node as unknown as HTMLInputElement).type === 'checkbox' && node.parentNode?.nodeName === 'LI'
},
replacement: function (content: string, node) {
return (node.checked ? '[x]' : '[ ]') + ' '