Using in TypeScript with react-markdown raises an error
See original GitHub issueSubject of the issue
Using with react-markdown raises an error
Your environment
- macOS 10.15.7 Catalina:
- react-markdown:
- Node.js v14.16.1:
Steps to reproduce
With following codes
import React from "react";
import ReactMarkdown from "react-markdown";
import { attacher, handler } from "./original-message";
import mdast2hast from "remark-rehype";
const SAMPLE = `
:::message
This is a message
:::
`;
function App() {
return (
<>
<h1>This is a Markdown</h1>
<ReactMarkdown
remarkPlugins={[
attacher,
[
mdast2hast,
{
handlers: {
message: handler,
},
},
],
]}
children={SAMPLE}
/>
</>
);
}
export default App;
Expected behavior
Any errors are not raised
Actual behavior
Following error is raised from TypeScript
Type 'Plugin<[(Options | undefined)?] | [(Processor<Settings> | undefined)?, (Options | undefined)?], Settings>' is not assignable to type 'Plugin<any[], Settings>'.
Types of parameters 'settings' and 'settings' are incompatible.
Type 'any[]' is not assignable to type '[(Options | undefined)?] | [(Processor<Settings> | undefined)?, (Options | undefined)?]'.
Type 'any[]' is not assignable to type '[(Processor<Settings> | undefined)?, (Options | undefined)?]'. TS2322
28 | attacher,
29 | [
> 30 | mdast2hast,
| ^
31 | {
32 | handlers: {
33 | message: handler,
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
react-markdown import error with nextjs 11.1 and typescript
You need to force the ReactMarkdown to run on the client side const ReactMarkdown= dynamic(() => import('react-markdown'),{ ssr: false }).
Read more >How to use TypeScript with React: A tutorial with examples
Using TypeScript with React can increase development speed, improve code readability, and much more. Learn how to get yourself going.
Read more >Build and Deploy a Markdown Editor Using Next.js, TypeScript ...
The type mismatch error occurs because the style defined in CodeProps of react-markdown and the style defined in SyntaxHighlighterProps are different types. Fix ......
Read more >ts2604: jsx element type does not have any construct or call ...
HigherIncreases the frequency the app appears ... react markdown use in Typescript. error: TS2604: JSX element type 'Markdown' does not have any construct ......
Read more >Building a static blog using Gatsby (Typescript) and Strapi
This tutorial will show you how to build a blog using Gatsby (Typescript) for the frontend and Strapi as the backend.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wooorm Thank you for your polite reply 😆 This is the last comment from me
I feel you I’ll get used to this
I don’t know what you want to do, so it’s hard to suggest the best approach! But yeah, thats often a good way to go.