making blog on Next.js13 with tailwind, contentlayer and for syntax-highlighting, tried to use rehype-pretty-code and rehype-highlight libraries; but some type error keep coming up and i have no idea how to handle this. below 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("/Users/joonpark/Desktop/Projects/nextjs/joon-dev-blog/node_modules/vfile/lib/index").VFile' is not assignable to type 'import("/Users/joonpark/Desktop/Projects/nextjs/joon-dev-blog/node_modules/rehype-highlight/node_modules/vfile/lib/index").VFile'.
Types of property 'messages' are incompatible.
Type 'import("/Users/joonpark/Desktop/Projects/nextjs/joon-dev-blog/node_modules/vfile/node_modules/vfile-message/lib/index").VFileMessage[]' is not assignable to type 'import("/Users/joonpark/Desktop/Projects/nextjs/joon-dev-blog/node_modules/vfile-message/lib/index").VFileMessage[]'.
Type 'VFileMessage' is missing the following properties from type 'VFileMessage': ancestors, place
and this is my contentlayer.config.ts file
import { defineDocumentType, makeSource } from 'contentlayer/source-files';
import rehypeHighlight from 'rehype-highlight';
import rehypePrettyCode from 'rehype-pretty-code';
import remarkGfm from 'remark-gfm';
export const Post = defineDocumentType(() => ({
name: 'Post',
filePathPattern: `**/*.mdx`,
fields: {
title: { type: 'string', required: true },
date: { type: 'date', required: true },
},
computedFields: {
url: {
type: 'string',
resolve: (post) => `/posts/${post._raw.flattenedPath}`,
},
},
}));
/** @type {import('rehype-pretty-code').Options} */
const options = {
theme: 'one-dark-pro',
};
export default makeSource({
contentDirPath: 'posts',
documentTypes: [Post],
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [[rehypePrettyCode, options], rehypeHighlight],
},
});
I did googlings, asked chatGPT(poor answer). And only seen a few similar cases in github issue, but all I got need to update the library and for current version should be not a problem.
Have anyone the idea of what kind type error is it? shoud I edit index.d.ts file from module folder??
I got exactly same problem and I can't solve it. So I add
ignoreBuildErrors: truetonext.config.jsto by pass it. It works when usingnpm run buildHope that this will help