diff --git a/packages/types/app/index.d.ts b/packages/types/app/index.d.ts index b4d20ea7eb..b27021ef19 100644 --- a/packages/types/app/index.d.ts +++ b/packages/types/app/index.d.ts @@ -3,6 +3,7 @@ import { IncomingMessage } from 'connect' import Vue, { ComponentOptions } from 'vue' import VueRouter, { Location, Route } from 'vue-router' import { Store } from 'vuex' +import { NuxtRuntimeConfig } from '../config/runtime' // augment typings of Vue.js import './vue' @@ -13,6 +14,8 @@ import './vuex' type NuxtState = Record export interface Context { + $config: NuxtRuntimeConfig + app: NuxtAppOptions base: string /** diff --git a/packages/types/app/vue.d.ts b/packages/types/app/vue.d.ts index a58897e20b..3832cdd8f1 100644 --- a/packages/types/app/vue.d.ts +++ b/packages/types/app/vue.d.ts @@ -2,10 +2,11 @@ * Extends interfaces in Vue.js */ -import Vue, { ComponentOptions } from 'vue' +import Vue from 'vue' import { MetaInfo } from 'vue-meta' import { Route } from 'vue-router' import { Context, Middleware, Transition, NuxtApp } from './index' +import { NuxtRuntimeConfig } from '../config/runtime' declare module 'vue/types/options' { interface ComponentOptions { @@ -28,6 +29,7 @@ declare module 'vue/types/options' { declare module 'vue/types/vue' { interface Vue { + $config: NuxtRuntimeConfig $nuxt: NuxtApp $fetch(): void $fetchState: { diff --git a/packages/types/config/index.d.ts b/packages/types/config/index.d.ts index 23e9697314..22b8c0a72a 100644 --- a/packages/types/config/index.d.ts +++ b/packages/types/config/index.d.ts @@ -13,6 +13,7 @@ import { NuxtOptionsModule } from './module' import { NuxtOptionsPlugin } from './plugin' import { NuxtOptionsRender } from './render' import { NuxtOptionsRouter } from './router' +import { NuxtConfigurationRuntimeConfig } from './runtime' import { NuxtOptionsServer } from './server' import { NuxtOptionsServerMiddleware } from './server-middleware' import { NuxtOptionsVueConfiguration } from './vue-configuration' @@ -50,6 +51,8 @@ export interface NuxtOptions extends Record { modules: NuxtOptionsModule[] modulesDir: string[] plugins: NuxtOptionsPlugin[] + privateRuntimeConfig?: NuxtConfigurationRuntimeConfig + publicRuntimeConfig?: NuxtConfigurationRuntimeConfig render: NuxtOptionsRender rootDir: string router: NuxtOptionsRouter diff --git a/packages/types/config/runtime.d.ts b/packages/types/config/runtime.d.ts new file mode 100644 index 0000000000..ff6bc487fb --- /dev/null +++ b/packages/types/config/runtime.d.ts @@ -0,0 +1,10 @@ +/** +* NuxtConfigurationRuntimeConfig +* NuxtRuntimeConfig interface can be extended by users to enable intellisense on $config +*/ + +export interface NuxtRuntimeConfig { + [key: string]: any +} + +export type NuxtConfigurationRuntimeConfig = NuxtRuntimeConfig | ((env: typeof process.env) => NuxtRuntimeConfig)