-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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: properly type-check the Docusaurus config of new sites #5589
Conversation
Remember there are two configs: one user-provided, and one after Joi normalization. The code expects the one after normalization where all these keys actually exist, therefore the current fix doesn't work. I think a more sensible fix is to provide another |
I like the export interface UserDocusaurusConfig extends Partial<DocusaurusConfig> {
baseUrl: string;
url: string;
title: string;
} |
That looks good to me. Are you sure the required fields include and only include these keys?🧐 |
Seems like it. I based that from the |
✔️ [V2] 🔨 Explore the source changes: 0538186 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6155d6e2556ccf000841173c 😎 Browse the preview: https://deploy-preview-5589--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5589--docusaurus-2.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserDocusaurusConfig
is nice but this is public API surface that we should also add in our doc and init templates JSDoc annotations.
Isn't it confusing to for users to have UserDocusaurusConfig
(in config) + DocusaurusConfig
(in code, pages etc...)?
There are other naming possibilities like DocusaurusConfig
+ DocusaurusConfigNormalized
, which is better?
Is there another better alternative?
Since this is a regular pattern to have partial user inputs that get normalized, we should find and stick to a shared convention for type names, particularly when they are documented as public API like in this case.
Not many users use the
Not saying |
It's in the JSDoc template so it's in a few newly initialized sites already I'm fine with |
I meant the actual |
|
# Conflicts: # packages/docusaurus-plugin-content-blog/package.json # packages/docusaurus-preset-classic/src/preset-classic.d.ts # packages/docusaurus-theme-common/package.json # packages/docusaurus-theme-common/src/utils/useThemeConfig.ts
FYI I used the export Using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR is ready for me and we have better config typechecking running in our CI now
Just not sure why some Prettier changes merged recently are reverted 😅
Could it be a local version incompatibility? I suppose you have run |
After restarting Intellij, it seems fixed :) |
PR created by @bmiddha, completed by @slorber
Motivation
Config
,ThemeConfig
and pluginOptions
(raw, unnormalized types)// @ts-check
for all new sites (+ Docusaurus site)Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Site config errors should be reported on
yarn workspace website typecheck
CI should pass, ensuring our own site config is valid
Related Issues
closes #5588