feat: properly type-check the Docusaurus config of new sites#5589
feat: properly type-check the Docusaurus config of new sites#5589slorber merged 13 commits intofacebook:mainfrom
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/ |
slorber
left a comment
There was a problem hiding this comment.
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 |
slorber
left a comment
There was a problem hiding this comment.
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,ThemeConfigand pluginOptions(raw, unnormalized types)// @ts-checkfor 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 typecheckCI should pass, ensuring our own site config is valid
Related Issues
closes #5588