Getting TS error Transformer<Root, Root>' is not assignable to type 'Plugin<any[], any, any>'.
khanakia opened this issue · comments
I am getting the below error however the code works fine when I compile
import { MDXRemote } from 'next-mdx-remote/rsc';
import rehypePrettyCode from 'rehype-pretty-code';
export default async function Page({ params }: any) {
return (
<MDXRemote
source={`test`}
options={{
mdxOptions: {
rehypePlugins: [rehypePrettyCode],
},
}}
/>
);
}
This type error is because next-mdx-remote
uses an old version of vfile
.
The main issue in your example is:
Type 'VFileMessage' is missing the following properties from type 'VFileMessage': ancestors
vfile
v6 has those properties whereas v5.3 which next-mdx-remote
uses doesn't. So the issue is next-mdx-remote
is using an older version of vfile
dependency:
https://github.com/hashicorp/next-mdx-remote/blob/main/package.json#L17
rehype-pretty-code
uses the latest version of unified
which has vfile
^6 as a dependency:
https://github.com/unifiedjs/unified/blob/b69689bba52a918d87aa62f295ccffa8d9aa8ef8/package.json#L54
cc @atomiks
Seems that next-mdx-remote
should update to latest unified
/vfile
dependencies. For now, you can ignore the type error since runtime works fine.