Просмотр исходного кода

Revert "dont use declare"

This reverts commit 14cad0ff98343b58c0f3901daf669057fe70ebcf.
reiji-h 1 год назад
Родитель
Сommit
8370a735db
1 измененных файлов с 11 добавлено и 5 удалено
  1. 11 5
      packages/remark-drawio/src/services/renderer/remark-drawio.ts

+ 11 - 5
packages/remark-drawio/src/services/renderer/remark-drawio.ts

@@ -1,4 +1,3 @@
-import type { Properties } from 'hast';
 import type { Schema as SanitizeOption } from 'hast-util-sanitize';
 import type {
   Code, Node, Paragraph,
@@ -8,9 +7,16 @@ import { visit } from 'unist-util-visit';
 
 const SUPPORTED_ATTRIBUTES = ['diagramIndex', 'bol', 'eol'];
 
-interface Data {
-  hName?: string,
-  hProperties?: Properties,
+declare module 'mdast' {
+  interface Data {
+    hName?: string,
+    hProperties?: {
+      diagramIndex?: number,
+      bol?: number,
+      eol?: number,
+      key?: string,
+    }
+  }
 }
 
 type Lang = 'drawio';
@@ -24,7 +30,7 @@ function rewriteNode(node: Node, index: number) {
   node.type = 'paragraph';
   (node as Paragraph).children = [{ type: 'text', value: (node as Code).value }];
 
-  const data: Data = node.data ?? (node.data = {});
+  const data = node.data ?? (node.data = {});
   data.hName = 'drawio';
   data.hProperties = {
     diagramIndex: index,