From a5deaefd807843c4da5942076d2dbf3381a13df8 Mon Sep 17 00:00:00 2001 From: Jie Date: Wed, 28 Aug 2024 22:47:01 +0800 Subject: [PATCH] fix: update tsconfig for build error --- src/index.ts | 31 ++++++++++++++++--------------- tsconfig.json | 10 ++++++++-- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7c7974f..0f33511 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,10 +22,14 @@ import { * Callout object with callout type as its key and icon as its value * @date 3/23/2023 - 5:16:27 PM * - * @typedef {Callout} */ type Callout = Record; +interface ExtendedNode extends Node { + data?: { + hProperties?: Record; + }; +} interface HtmlNode extends Node { type: "html"; data: Data; @@ -38,7 +42,6 @@ interface HtmlNode extends Node { * * @export * @interface Config - * @typedef {Config} */ export interface Config { /** @@ -183,9 +186,9 @@ function containsKey(obj: Callout, str: string): boolean { * @date 3/23/2023 - 5:16:26 PM * * @param {?Partial} [customConfig] - * @returns {(tree: any) => void} + * @returns {(tree: Node) => void} */ -const plugin: Plugin = (customConfig?: Partial) => { +const plugin: Plugin = (customConfig?: Partial): (tree: Node) => void => { const mergedConfig = { ...defaultConfig, ...customConfig, @@ -208,8 +211,8 @@ const plugin: Plugin = (customConfig?: Partial) => { titleTextTransform, } = mergedConfig; - return function (tree) { - visit(tree, "blockquote", (node: Node) => { + return function (tree: Node): void { + visit(tree, "blockquote", (node: ExtendedNode) => { if (!("children" in node) || (node as Parent).children.length == 0) return; @@ -238,15 +241,13 @@ const plugin: Plugin = (customConfig?: Partial) => { data: {}, value: `
- <${iconTagName} class="${iconClass}">${ - callouts[calloutType.toLowerCase()] - } - ${ - title && - `<${titleTextTagName} class="${titleTextClass}">${titleTextTransform( - title - )}` - } + <${iconTagName} class="${iconClass}">${callouts[calloutType.toLowerCase()] + } + ${title && + `<${titleTextTagName} class="${titleTextClass}">${titleTextTransform( + title + )}` + }
${remainingContent && `
${remainingContent}
`}`, }; diff --git a/tsconfig.json b/tsconfig.json index f33b68f..85bc732 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,13 @@ { - "include": ["src", "test"], + "include": [ + "src", + "test" + ], "compilerOptions": { - "lib": ["ESNext"], + "lib": [ + "ESNext", + "dom" + ], "module": "ESNext", "target": "ESNext", "strict": true,