Skip to content

Commit

Permalink
fix(types): sync defineConfig types with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jun 11, 2023
1 parent 4ddb96f commit b3ded34
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/node/config.ts
Expand Up @@ -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'
Expand All @@ -16,32 +17,36 @@ 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
}

/**
* Type config helper for custom theme config
*/
export function defineConfigWithTheme<ThemeConfig>(
config: UserConfig<ThemeConfig>
config: UserConfigExport<ThemeConfig>
) {
return config
}
Expand Down

0 comments on commit b3ded34

Please sign in to comment.