Skip to content

Commit f4e3376

Browse files
committed
type: optimization type. (#188)
1 parent 67a4591 commit f4e3376

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React, { useImperativeHandle } from 'react';
22
import ReactMarkdown, { Options } from 'react-markdown';
3-
import { Root, Element, ElementContent } from 'hast';
3+
import { Element } from 'hast';
44
import { PluggableList } from 'unified';
55
import gfm from 'remark-gfm';
66
import slug from 'rehype-slug';
77
import headings from 'rehype-autolink-headings';
88
import rehypeRaw from 'rehype-raw';
99
import rehypeAttrs from 'rehype-attr';
1010
import rehypePrism from 'rehype-prism-plus';
11-
import rehypeRewrite, { getCodeString } from 'rehype-rewrite';
11+
import rehypeRewrite, { getCodeString, RehypeRewriteOptions } from 'rehype-rewrite';
1212
import { octiconLink } from './nodes/octiconLink';
1313
import { copyElement } from './nodes/copy';
1414
import './styles/markdown.less';
@@ -50,7 +50,7 @@ export default React.forwardRef<MarkdownPreviewRef, MarkdownPreviewProps>((props
5050
useImperativeHandle(ref, () => ({ ...props, mdp }), [mdp, props]);
5151
const cls = `${prefixCls || ''} ${className || ''}`;
5252

53-
const rehypeRewriteHandle = (node: ElementContent, index: number | null, parent: Root | Element | null) => {
53+
const rehypeRewriteHandle: RehypeRewriteOptions['rewrite'] = (node, index, parent) => {
5454
if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
5555
const child = node.children && (node.children[0] as Element);
5656
if (child && child.properties && child.properties.ariaHidden === 'true') {

0 commit comments

Comments
 (0)