Improve TypeScript Types for ThemeConfig
Have you read the Contributing Guidelines on issues?
- [x] I have read the Contributing Guidelines on issues.
Description
I would like to suggest providing better TypeScript types for ThemeConfig to improve the developer experience.
Has this been requested on Canny?
No response
Motivation
Currently, the ThemeConfig type is defined as:
export type ThemeConfig = {
[key: string]: unknown;
};
As a result, developers are unable to benefit from IDE IntelliSense when configuring ThemeConfig within docusaurus.config.ts.
Improving the type definition would greatly enhance the DX by enabling better autocompletion, error checking, and documentation directly within the editor.
API design
No response
Have you tried building it?
No response
Self-service
- [ ] I'd be willing to contribute this feature to Docusaurus myself.
Agree, we should do that!
In the meantime, we have an incompletely typed API here:
import {useThemeConfig} from '@docusaurus/theme-common';
Ideally, we should refactor the code to use an interface and let each plugin enhance it with their own attributes with declaration merging. I'd prefer to do this refactor for v4 since it may break compilation for some sites.
@slorber any ETA on v4? Just curious to plan the update in our org.
I can't really give a date, but it's not coming before a few months.
We are still merging retro-compatible features. I plan to release v3.8 tomorrow, and eventually v3.9 later with a few extra feature flags to prepare for v4.
Regarding v4, we have a long list of breaking changes we want to do, and haven't started to work on some of them that may be complex, so I can't really give an estimate. We'll figure out depending on the complexity.
Hey @slorber , I would love to work upon this issue, could you please assign it to me.