我在我的反应项目中使用打字稿,但是当我使用this代码片段时,我收到错误
<ReactMarkdown rehypePlugins={[rehypeRaw]}>
{content}
</ReactMarkdown>
Type '(options?: void | Options | undefined) => void | Transformer<Root, Root>' is not assignable to type 'Pluggable<any[], Settings>'.
Type '(options?: void | Options | undefined) => void | Transformer<Root, Root>' is not assignable to type 'Plugin<any[], Settings>'.
Type 'void | Transformer<Root, Root>' is not assignable to type 'void | Transformer'.
Type 'Transformer<Root, Root>' is not assignable to type 'void | Transformer'.
Type 'Transformer<Root, Root>' is not assignable to type 'Transformer'.
Types of parameters 'node' and 'node' are incompatible.
关于该类型错误有什么想法吗?
我遇到了同样的错误。我通过为
as any
添加类型断言
rehypePlugins
来修复它
<Markdown
rehypePlugins={[rehypeRaw] as any}
>
{content}
</Markdown>
现在可以了。希望它也适合您。