Skip to content

ResolvedConfig interface #15473

Closed
Closed
@unicornware

Description

Description

ResolvedConfig is currently defined as a type, but it should be an interface.

Unlike with UserConfig, this means declaration merging cannot be taken advantage of by plugin developers. As a TypeScript developer, this makes typing resolved plugin options unnecessarily difficult. Sharing those options with other plugin developers is not possible without declaration merging, or alternatively, cumbersome and possibly out-of-date patches.

Suggested solution

// packages/vite/src/node/config.ts

interface ResolvedConfig extends Readonly<
  Omit<
    UserConfig,
    | 'assetsInclude'
    | 'build'
    | 'css'
    | 'optimizeDeps'
    | 'plugins'
    | 'worker'
  > & PluginHookUtils
> {
    readonly appType: AppType
    readonly assetsInclude(file: string): boolean
    readonly base: string
    readonly build: ResolvedBuildOptions
    readonly cacheDir: string
    readonly command: 'build' | 'serve'
    readonly configFile: string | undefined
    readonly configFileDependencies: string[]
    readonly createResolver(
      options?: Partial<InternalResolveOptions>
    ): ResolveFn
    readonly css: ResolvedCSSOptions
    readonly env: Record<string, any>
    readonly envDir: string
    readonly esbuild: ESBuildOptions | false
    readonly experimental: ExperimentalOptions
    readonly inlineConfig: InlineConfig
    readonly isProduction: boolean
    readonly isWorker: boolean
    readonly logger: Logger
    readonly mainConfig: ResolvedConfig | null
    readonly mode: string
    readonly optimizeDeps: DepOptimizationOptions
    readonly packageCache: PackageCache
    readonly plugins: readonly Plugin[]
    readonly preview: ResolvedPreviewOptions
    readonly publicDir: string
    readonly rawBase: string
    readonly resolve: Required<ResolveOptions> & { alias: Alias[] }
    readonly root: string
    readonly server: ResolvedServerOptions
    readonly ssr: ResolvedSSROptions
    readonly worker: ResolvedWorkerOptions
}

Alternative

No response

Additional context

The documentation gives the impression ResolvedConfig is an interface. Given the docs, I wasn't sure if this should be a feature request or bug report 😅

Validations

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions