kentcdodds / mdx-bundler

🦤 Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!
MIT License
1.78k stars 75 forks source link

fix: type error in options parameter of mdxOptions #219

Closed CottonCandyZ closed 10 months ago

CottonCandyZ commented 1 year ago

What: Change the type of the options parameter in the mdxOptions function from the original ProcessorOptions to Option, which is the CompileOptions type.

Why: After upgrading the @mdx-js dependency to version 3.0, there have been some changes in the Options defined in @mdx-js/esbuild/lib. This change has made the previously used ProcessorOptions invalid, causing a type error for the options parameter when using mdxOptions in TypeScript.

How: Read the doc about ProcessorOptions and CompileOptions and find that need to use CompileOptions here.

Checklist:

@mdx-js/esbuild/lib exports CompileOptions and an equivalent type called Options. I'm not sure which one is more appropriate to use here. In this commit, I have chosen Options.

kentcdodds commented 10 months ago

Looks like this failed to typecheck: https://github.com/kentcdodds/mdx-bundler/actions/runs/7547192375

CottonCandyZ commented 10 months ago

Looks like this failed to typecheck: https://github.com/kentcdodds/mdx-bundler/actions/runs/7547192375

Thank you for your reply! It seems that remark-mdx-images v2.0 references unified v10, causing the Plugin type error. Upgrading remark-mdx-images to v3.0 will fix this error, as it will reference unified v11, which uses the new Plugin type. The original ProcessorOptions type does not exist in @mdx-js/esbuild/lib, which causes the type of remarkPlugins to be any. I believe the new Options type would be more appropriate.

kentcdodds commented 10 months ago

Ah, would you like to try again with another PR?

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 10.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: