From 0d9e260a6a21e19d77c7778720cc13a503ab400f Mon Sep 17 00:00:00 2001 From: ppxb <317842449@qq.com> Date: Sat, 10 Jan 2026 14:07:28 +0800 Subject: [PATCH] fix: vite.config.mts type error (#7081) --- internal/vite-config/src/config/index.ts | 4 ++-- internal/vite-config/src/typing.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/vite-config/src/config/index.ts b/internal/vite-config/src/config/index.ts index d04a84a8..b8c770a9 100644 --- a/internal/vite-config/src/config/index.ts +++ b/internal/vite-config/src/config/index.ts @@ -1,4 +1,4 @@ -import type { DefineConfig } from '../typing'; +import type { DefineConfig, VbenViteConfig } from '../typing'; import { existsSync } from 'node:fs'; import { join } from 'node:path'; @@ -12,7 +12,7 @@ export * from './library'; function defineConfig( userConfigPromise?: DefineConfig, type: 'application' | 'auto' | 'library' = 'auto', -) { +): VbenViteConfig { let projectType = type; // 根据包是否存在 index.html,自动判断类型 diff --git a/internal/vite-config/src/typing.ts b/internal/vite-config/src/typing.ts index f730bdb9..2dd04830 100644 --- a/internal/vite-config/src/typing.ts +++ b/internal/vite-config/src/typing.ts @@ -1,5 +1,10 @@ import type { PluginVisualizerOptions } from 'rollup-plugin-visualizer'; -import type { ConfigEnv, PluginOption, UserConfig } from 'vite'; +import type { + ConfigEnv, + PluginOption, + UserConfig, + UserConfigFnPromise, +} from 'vite'; import type { PluginOptions } from 'vite-plugin-dts'; import type { Options as PwaPluginOptions } from 'vite-plugin-pwa'; @@ -327,6 +332,8 @@ type DefineLibraryOptions = (config?: ConfigEnv) => Promise<{ */ type DefineConfig = DefineApplicationOptions | DefineLibraryOptions; +type VbenViteConfig = Promise | UserConfig | UserConfigFnPromise; + export type { ApplicationPluginOptions, ArchiverPluginOptions, @@ -340,4 +347,5 @@ export type { LibraryPluginOptions, NitroMockPluginOptions, PrintPluginOptions, + VbenViteConfig, };