Skip to content

Commit b9d8419

Browse files
committed
update type helpers
1 parent e835777 commit b9d8419

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/node/config.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
slash,
2020
type AdditionalConfig,
2121
type AdditionalConfigDict,
22+
type Awaitable,
2223
type HeadConfig,
2324
type SiteData
2425
} from './shared'
@@ -34,46 +35,47 @@ const resolve = (root: string, file: string) =>
3435

3536
export type UserConfigFn<ThemeConfig> = (
3637
env: ConfigEnv
37-
) => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>
38+
) => Awaitable<UserConfig<ThemeConfig>>
3839
export type UserConfigExport<ThemeConfig> =
39-
| UserConfig<ThemeConfig>
40-
| Promise<UserConfig<ThemeConfig>>
40+
| Awaitable<UserConfig<ThemeConfig>>
4141
| UserConfigFn<ThemeConfig>
4242

4343
/**
4444
* Type config helper
4545
*/
46-
export function defineConfig(config: UserConfig<DefaultTheme.Config>) {
46+
export function defineConfig<ThemeConfig = DefaultTheme.Config>(
47+
config: UserConfig<NoInfer<ThemeConfig>>
48+
) {
4749
return config
4850
}
4951

52+
export type AdditionalConfigFn<ThemeConfig> = (
53+
env: ConfigEnv
54+
) => Awaitable<AdditionalConfig<ThemeConfig>>
55+
export type AdditionalConfigExport<ThemeConfig> =
56+
| Awaitable<AdditionalConfig<ThemeConfig>>
57+
| AdditionalConfigFn<ThemeConfig>
58+
5059
/**
51-
* Type additional config helper
60+
* Type config helper for additional/locale-specific config
5261
*/
53-
export function defineAdditionalConfig(
54-
config: AdditionalConfig<DefaultTheme.Config>
62+
export function defineAdditionalConfig<ThemeConfig = DefaultTheme.Config>(
63+
config: AdditionalConfig<NoInfer<ThemeConfig>>
5564
) {
5665
return config
5766
}
5867

5968
/**
6069
* Type config helper for custom theme config
70+
*
71+
* @deprecated use `defineConfig` instead
6172
*/
6273
export function defineConfigWithTheme<ThemeConfig>(
6374
config: UserConfig<ThemeConfig>
6475
) {
6576
return config
6677
}
6778

68-
/**
69-
* Type additional config helper
70-
*/
71-
export function defineAdditionalConfigWithTheme<ThemeConfig>(
72-
config: AdditionalConfig<ThemeConfig>
73-
) {
74-
return config
75-
}
76-
7779
export async function resolveConfig(
7880
root: string = process.cwd(),
7981
command: 'serve' | 'build' = 'serve',

0 commit comments

Comments
 (0)