From b3ded34d8a9ca7a9a82e9b0cf705a2ed6233e881 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 11 Jun 2023 12:22:38 +0530 Subject: [PATCH] fix(types): sync defineConfig types with vite --- src/node/config.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/node/config.ts b/src/node/config.ts index d9962bdf..4353f4d1 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -6,7 +6,8 @@ import { createLogger, loadConfigFromFile, mergeConfig as mergeViteConfig, - normalizePath + normalizePath, + type ConfigEnv } from 'vite' import { DEFAULT_THEME_PATH } from './alias' import { resolvePages } from './plugins/dynamicRoutesPlugin' @@ -16,24 +17,28 @@ import { type HeadConfig, type SiteData } from './shared' -import { - type UserConfig, - type RawConfigExports, - type SiteConfig -} from './siteConfig' +import type { RawConfigExports, SiteConfig, UserConfig } from './siteConfig' -export * from './siteConfig' export { resolvePages } from './plugins/dynamicRoutesPlugin' +export * from './siteConfig' const debug = _debug('vitepress:config') const resolve = (root: string, file: string) => normalizePath(path.resolve(root, `.vitepress`, file)) +export type UserConfigFn = ( + env: ConfigEnv +) => UserConfig | Promise> +export type UserConfigExport = + | UserConfig + | Promise> + | UserConfigFn + /** * Type config helper */ -export function defineConfig(config: UserConfig) { +export function defineConfig(config: UserConfigExport) { return config } @@ -41,7 +46,7 @@ export function defineConfig(config: UserConfig) { * Type config helper for custom theme config */ export function defineConfigWithTheme( - config: UserConfig + config: UserConfigExport ) { return config }