From e0125f49ffbe64af1223cd674562d7ca7ad002d2 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 6 May 2022 14:27:42 +0100 Subject: [PATCH] fix(schema): add back `PublicRuntimeConfig` interface for augmentation (#4849) --- packages/nuxt/src/core/templates.ts | 10 +++++++++- packages/schema/src/types/config.ts | 11 ++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index 2604a7b416..a879599789 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -135,7 +135,7 @@ export const schemaTemplate = { ` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends NuxtModule ? Partial : Record` ), ' }', - 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') } diff --git a/packages/schema/src/types/config.ts b/packages/schema/src/types/config.ts index 0446e1aa26..827c3fbdc6 100644 --- a/packages/schema/src/types/config.ts +++ b/packages/schema/src/types/config.ts @@ -16,15 +16,12 @@ export interface NuxtOptions extends ConfigSchema { type RuntimeConfigNamespace = Record -/** @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 - -export interface RuntimeConfig extends LegacyRuntimeConfig, RuntimeConfigNamespace { - app: RuntimeConfigNamespace - public: RuntimeConfigNamespace +export interface RuntimeConfig extends PrivateRuntimeConfig, RuntimeConfigNamespace { + public: PublicRuntimeConfig }