Skip to content

Commit d7086c2

Browse files
committed
type: Fix type error in react-markdown v7 #102
1 parent 72fd88a commit d7086c2

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import React, { useImperativeHandle } from 'react';
2-
import ReactMarkdown from 'react-markdown';
3-
// @ts-ignore
2+
import ReactMarkdown, { Options } from 'react-markdown';
43
import gfm from 'remark-gfm';
5-
// @ts-ignore
64
import slug from 'remark-slug';
7-
// @ts-ignore
85
import headings from 'remark-autolink-headings'
9-
// @ts-ignore
106
import rehypeRaw from 'rehype-raw';
117
import rehypePrism from '@mapbox/rehype-prism';
12-
// @ts-ignore
138
import rehypeRewrite from 'rehype-rewrite';
149
import './styles/markdown.less';
1510
import './styles/markdowncolor.less';
@@ -54,7 +49,7 @@ export type MarkdownPreviewProps = {
5449
warpperElement?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
5550
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
5651
onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
57-
} & Omit<ReactMarkdown.ReactMarkdownOptions, 'children'>;
52+
} & Omit<Options, 'children'>;
5853

5954
export type MarkdownPreviewRef = {
6055
mdp: React.RefObject<HTMLDivElement>;
@@ -69,7 +64,7 @@ export default React.forwardRef<MarkdownPreviewRef, MarkdownPreviewProps>((props
6964
<div ref={mdp} onScroll={onScroll} onMouseOver={onMouseOver} {...warpperElement} className={cls} style={style}>
7065
<ReactMarkdown
7166
{...other}
72-
rehypePlugins={[[rehypePrism, { ignoreMissing: true }], [rehypeRewrite, rehypeRewriteHandle], rehypeRaw, ...(other.rehypePlugins || [])]}
67+
rehypePlugins={[[rehypePrism, { ignoreMissing: true }], [rehypeRewrite as any, rehypeRewriteHandle], rehypeRaw, ...(other.rehypePlugins || [])]}
7368
remarkPlugins={[ slug, headings, ...(other.remarkPlugins || []), gfm ]}
7469
children={source || ''}
7570
/>

0 commit comments

Comments
 (0)