question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using in TypeScript with react-markdown raises an error

See original GitHub issue

Subject 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
januswelcommented, Apr 21, 2021

@wooorm Thank you for your polite reply 😆 This is the last comment from me

Though I do get that it’s weird at first.

I feel you I’ll get used to this

1reaction
wooormcommented, Apr 21, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found