Skip to content
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

[Feature Request] Improve TypeScript support for config file. #464

Closed
4 tasks done
ulivz opened this issue Dec 11, 2021 · 0 comments · Fixed by #465
Closed
4 tasks done

[Feature Request] Improve TypeScript support for config file. #464

ulivz opened this issue Dec 11, 2021 · 0 comments · Fixed by #465

Comments

@ulivz
Copy link
Member

ulivz commented Dec 11, 2021

Is your feature request related to a problem? Please describe.

Make configuration easier.

Describe the solution you'd like

Same as vite :

import { defineConfig } from 'vitepress'

export default defineConfig({
   lang: 'en-US',
   // ...
}) 

But we need to improve the support for theme config:

By default, defineConfig helper leverages the theme config type from default theme:

import { defineConfig } from 'vitepress'

export default defineConfig({
  themeConfig: {
     // Type is `DefaultTheme.Config` 
  }
})

If you use a custom theme, you'll be able to pass the generics type for your custom theme, and you need overload it with the second parameter of defineConfig helper:

import { defineConfig } from 'vitepress'
import { ThemeConfig } from 'your-theme'

export default defineConfig<ThemeConfig>({
  themeConfig: {
    // Type is `ThemeConfig` 
  }
}, true); // declare `usingCustomTheme` and discard usage of the default theme.

Describe alternatives you've considered

No response

Additional context

No response

Validations

@ulivz ulivz changed the title [Feature Request] TypeScript support for config file. [Feature Request] Improve TypeScript support for config file. Dec 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant