docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Improve TypeScript Types for ThemeConfig

Open peterpeterparker opened this issue 7 months ago • 4 comments

Have you 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.

peterpeterparker avatar May 21 '25 10:05 peterpeterparker

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 avatar May 21 '25 15:05 slorber

@slorber any ETA on v4? Just curious to plan the update in our org.

philippnagel avatar May 22 '25 10:05 philippnagel

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.

slorber avatar May 22 '25 17:05 slorber

Hey @slorber , I would love to work upon this issue, could you please assign it to me.

Vedant817 avatar Oct 22 '25 18:10 Vedant817