fix(schema): add back PublicRuntimeConfig interface for augmentation (#4849)

This commit is contained in:
Daniel Roe 2022-05-06 14:27:42 +01:00 committed by GitHub
parent a5ba1df37a
commit e0125f49ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -135,7 +135,7 @@ export const schemaTemplate = {
` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`
),
' }',
generateTypes(resolveSchema(nuxt.options.runtimeConfig),
generateTypes(resolveSchema(Object.fromEntries(Object.entries(nuxt.options.runtimeConfig).filter(([key]) => key !== 'public'))),
{
interfaceName: 'RuntimeConfig',
addExport: false,
@ -143,6 +143,14 @@ export const schemaTemplate = {
allowExtraKeys: false,
indentation: 2
}),
generateTypes(resolveSchema(nuxt.options.runtimeConfig.public),
{
interfaceName: 'PublicRuntimeConfig',
addExport: false,
addDefaults: false,
allowExtraKeys: false,
indentation: 2
}),
'}'
].join('\n')
}

View File

@ -16,15 +16,12 @@ export interface NuxtOptions extends ConfigSchema {
type RuntimeConfigNamespace = Record<string, any>
/** @deprecated use RuntimeConfig interface */
export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
// TODO: remove before release of 3.0.0
/** @deprecated use RuntimeConfig interface */
export interface PrivateRuntimeConfig extends PublicRuntimeConfig { }
export interface PrivateRuntimeConfig extends RuntimeConfigNamespace { }
type LegacyRuntimeConfig = PublicRuntimeConfig & Partial<PrivateRuntimeConfig>
export interface RuntimeConfig extends LegacyRuntimeConfig, RuntimeConfigNamespace {
app: RuntimeConfigNamespace
public: RuntimeConfigNamespace
export interface RuntimeConfig extends PrivateRuntimeConfig, RuntimeConfigNamespace {
public: PublicRuntimeConfig
}