fix(types): sync defineConfig types with vite

pull/2495/head
Divyansh Singh 1 year ago
parent 4ddb96fe50
commit b3ded34d8a

@ -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<ThemeConfig> = (
env: ConfigEnv
) => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>
export type UserConfigExport<ThemeConfig> =
| UserConfig<ThemeConfig>
| Promise<UserConfig<ThemeConfig>>
| UserConfigFn<ThemeConfig>
/**
* Type config helper
*/
export function defineConfig(config: UserConfig<DefaultTheme.Config>) {
export function defineConfig(config: UserConfigExport<DefaultTheme.Config>) {
return config
}
@ -41,7 +46,7 @@ export function defineConfig(config: UserConfig<DefaultTheme.Config>) {
* Type config helper for custom theme config
*/
export function defineConfigWithTheme<ThemeConfig>(
config: UserConfig<ThemeConfig>
config: UserConfigExport<ThemeConfig>
) {
return config
}

Loading…
Cancel
Save