-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat: export CreateSitemapItemsOption type #10105
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
I'd prefer to not export it. Options are easily accessible and many other plugins to not export types. Once we export them, we must have a good name and maintain retrocompatibility. The type gymnastic is not super hard, particularly when not using JSDoc but using plain TS const createSitemapItems: Options['createSitemapItems'] = async (params) => {
return params.defaultCreateSitemapItems(params);
}; If we expose this, then this means we'll also probably have users finding convenient to expose many other option types as well. And we end up with many exported types whose naming convention should be consistent, and for which we need to remain retrocompatible over time. |
It sounds like you've made up your mind already, but I thought it worth mentioning that not exporting the type doesn't align with the import('@docusaurus/plugin-content-blog').CreateFeedItemsFn Example usage of exported type here: Given we exported the type for that (comparable) functionality, why differ this time? See:
|
We export many things from docs, blog and pages plugin. I'm not sure it's the right decision actually to export everything by default like we do. If we can avoid exporting more things in the future, I'd prefer to not export them (at least until we have a clear plan on how to handle exported types), particularly when there is an easy workaround to get the type. Also those plugins have a |
Should we then look at removing the I guess I'm a little confused as to what the rationale is for when types should and should not be exported. Is it documented somewhere? |
I don't know 🙈
I am too, the way we handle types atm is messy and not super consistent. Until we have a clear plan (which we haven't), I'd rather not export more types unless it's really necessary. |
Fair enough! |
Pre-flight checklist
Motivation
This is a follow on from #10083
I realised when plugging it into my blog that I hadn't exported the type.
It's possible to do some type gymnastics to get to it:
https://github.com/johnnyreilly/blog.johnnyreilly.com/blob/e38e4615e8afb9d66a59e607de04f46ec927a96d/blog-website/createSitemapItems.mjs#L6C1-L10C49
But it would be nicer if it was just exposed. This PR exposes the type explicity.
Test Plan
I tried to import in
docusaurus.config.ts
and it worked!Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
#10083