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

TS issue rehypeKatex #783

Closed
4 tasks done
vincentleeuwen opened this issue Oct 18, 2023 · 2 comments
Closed
4 tasks done

TS issue rehypeKatex #783

vincentleeuwen opened this issue Oct 18, 2023 · 2 comments
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on

Comments

@vincentleeuwen
Copy link

Initial checklist

Affected packages and versions

    "katex": "^0.16.9",        "rehype-katex": "^7.0.0",         "remark-math": "^6.0.0",

Link to runnable example

No response

Steps to reproduce

I use node v20.2.0 & npm 9.6.6.

Love the library, have a quick question about the math plugin. I installed the following versions:

"katex": "^0.16.9",
"rehype-katex": "^7.0.0",
"remark-math": "^6.0.0",
"react-markdown": "^8.0.7",

Followed implementation as described in README:

import ReactMarkdown from 'react-markdown';
import rehypeKatex from 'rehype-katex';
import remarkMath from 'remark-math';
import 'katex/dist/katex.min.css'

<ReactMarkdown
  remarkPlugins={[remarkMath]} 
  rehypePlugins={[rehypeKatex]}
>
  {children}
</ReactMarkdown>

Without the katex all is fine, but as soon as I try to add this, I receive the following typescript error:

Type '(options?: Readonly<Options> | null | undefined) => (tree: Root, file: VFile) => undefined' is not assignable to type 'Pluggable<any[]>'.
  Type '(options?: Readonly<Options> | null | undefined) => (tree: Root, file: VFile) => undefined' is not assignable to type 'Plugin<any[], any, any>'.
    Type '(tree: Root, file: VFile) => undefined' is not assignable to type 'void | Transformer<any, any>'.
      Type '(tree: Root, file: VFile) => undefined' is not assignable to type 'Transformer<any, any>'.
        Types of parameters 'file' and 'file' are incompatible.
          Type 'import("node_modules/vfile/lib/index").VFile' is not assignable to type 'import("node_modules/rehype-katex/node_modules/vfile/lib/index").VFile'.
            Types of property 'messages' are incompatible.
              Type 'import("node_modules/vfile-message/lib/index").VFileMessage[]' is not assignable to type 'import("node_modules/rehype-katex/node_modules/vfile-message/lib/index").VFileMessage[]'.
                Type 'VFileMessage' is missing the following properties from type 'VFileMessage': ancestors, place

Any ideas?

Expected behavior

The math notations show just fine in dev mode, which is really nice, but when I try to build (or in editor) TypeScript gives an error for the rehypePlugins={[rehypeKatex]} part.

Actual behavior

My project should still build after using rehypePlugins={[rehypeKatex]}.

Runtime

Other (please specify in steps to reproduce)

Package manager

Other (please specify in steps to reproduce)

OS

macOS

Build and bundle tools

Vite

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 18, 2023
@wooorm
Copy link
Member

wooorm commented Oct 18, 2023

Update all your dependencies and you are good!

@wooorm wooorm closed this as completed Oct 18, 2023
@github-actions

This comment has been minimized.

@wooorm wooorm added the 🤷 no/invalid This cannot be acted upon label Oct 18, 2023
@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants