Support MDX provider #399
Labels
🗄 area/interface
This affects the public interface
💪 phase/solved
Post is done
👶 semver/patch
This is a backwards-compatible fix
🦋 type/enhancement
This is great to have
Initial checklist
Problem
#260 adds support for the
components
prop. Another common way to inject custom components is using an MDX provider.Solution
Let the user define which components are provided via a reserved name, let’s call it
MDXProvidedComponents
. Much likeProps
, the language server assumes it will be available with some fallback logic. That means a user can write the following code to have the provided components available on a per-file basis. This is needed if multiple MDX providers are used.TypeScript also supports global types. This means that alternatively, the user can define the type globally and have it available in every document. This is the ideal solution if there’s only one MDX provider in the entire tree.
Alternatives
I looked into augmenting
@types/mdx
, but I don’t think that’s great. TheMDXComponents
is very loose, allows injecting any key. This is great for the developer DX we’re providing without this more advanced MDX language tooling, but we can do better if the user uses the MDX language server. I.e. it reduces the usefulness of autocomplete and validation.The text was updated successfully, but these errors were encountered: