Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error after upgrading any plugin to last version from previous version #627

Closed
4 tasks done
tairosonloa opened this issue Aug 7, 2021 · 1 comment
Closed
4 tasks done
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on

Comments

@tairosonloa
Copy link

tairosonloa commented Aug 7, 2021

Initial checklist

Affected packages and versions

react-markdown v6.0.3, remark-gfm v2.0.0, remark-unwrap-images v3.0.0

Link to runnable example

No response

Steps to reproduce

With the last version of react-markdown (v6.0.3), the following TypeScript code snippet will work fine with the plugins remark-gfm and remark-unwrap-images on versions v1.0.0 and v2.1.0 respectively.

import ReactMarkdown from 'react-markdown'
import gfm from 'remark-gfm'
import rum from 'remark-unwrap-images'

const BlogPage = ({ article }) => {
  return <ReactMarkdown
    remarkPlugins={[gfm, rum]}
  >
    {article.body_markdown}
  </ReactMarkdown>
}

However, if I update any of the plugin from that version (the immediately previous one) to the last version, I get the following errors for each:

For remark-gfm:

Type error: 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.
            Property 'children' is missing in type 'Node' but required in type 'Root'.

           <ReactMarkdown
             remarkPlugins={[gfm, rum]}
                             ^
           >

For remark-unwrap-images (note the errors refers gfm, but I have only updated remark-unwrap-images, so there could be a type inference problem with the TS compiler):

Type error: Type 'Gfm' is not assignable to type 'Pluggable<any[], Settings>'.
--
  Type 'Gfm' is not assignable to type 'Plugin<any[], Settings>'.
    The 'this' types of each signature are incompatible.
      Property 'attachers' is missing in type 'Processor<Settings>' but required in type 'Processor<void, Node, void, void>'.

           <ReactMarkdown
             remarkPlugins={[gfm, rum]}
                             ^
           >

Expected behavior

Not to get errors and execute it properly

Actual behavior

Getting the errors I posted

Runtime

Node v14

Package manager

yarn v1

OS

Linux, macOS

Build and bundle tools

Next.js

@wooorm wooorm added the 👀 no/external This makes more sense somewhere else label Aug 7, 2021
@wooorm
Copy link
Member

wooorm commented Aug 7, 2021

See rehypejs/rehype#63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants