mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
feat(types): add runtimeConfig types (nuxt/typescript#368)
Co-Authored-By: Kevin Marrec <kevin@marrec.io>
This commit is contained in:
parent
99432d5d94
commit
b6e8b74833
3
packages/types/app/index.d.ts
vendored
3
packages/types/app/index.d.ts
vendored
@ -3,6 +3,7 @@ import { IncomingMessage } from 'connect'
|
|||||||
import Vue, { ComponentOptions } from 'vue'
|
import Vue, { ComponentOptions } from 'vue'
|
||||||
import VueRouter, { Location, Route } from 'vue-router'
|
import VueRouter, { Location, Route } from 'vue-router'
|
||||||
import { Store } from 'vuex'
|
import { Store } from 'vuex'
|
||||||
|
import { NuxtRuntimeConfig } from '../config/runtime'
|
||||||
|
|
||||||
// augment typings of Vue.js
|
// augment typings of Vue.js
|
||||||
import './vue'
|
import './vue'
|
||||||
@ -13,6 +14,8 @@ import './vuex'
|
|||||||
type NuxtState = Record<string, any>
|
type NuxtState = Record<string, any>
|
||||||
|
|
||||||
export interface Context {
|
export interface Context {
|
||||||
|
$config: NuxtRuntimeConfig
|
||||||
|
|
||||||
app: NuxtAppOptions
|
app: NuxtAppOptions
|
||||||
base: string
|
base: string
|
||||||
/**
|
/**
|
||||||
|
4
packages/types/app/vue.d.ts
vendored
4
packages/types/app/vue.d.ts
vendored
@ -2,10 +2,11 @@
|
|||||||
* Extends interfaces in Vue.js
|
* Extends interfaces in Vue.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Vue, { ComponentOptions } from 'vue'
|
import Vue from 'vue'
|
||||||
import { MetaInfo } from 'vue-meta'
|
import { MetaInfo } from 'vue-meta'
|
||||||
import { Route } from 'vue-router'
|
import { Route } from 'vue-router'
|
||||||
import { Context, Middleware, Transition, NuxtApp } from './index'
|
import { Context, Middleware, Transition, NuxtApp } from './index'
|
||||||
|
import { NuxtRuntimeConfig } from '../config/runtime'
|
||||||
|
|
||||||
declare module 'vue/types/options' {
|
declare module 'vue/types/options' {
|
||||||
interface ComponentOptions<V extends Vue> {
|
interface ComponentOptions<V extends Vue> {
|
||||||
@ -28,6 +29,7 @@ declare module 'vue/types/options' {
|
|||||||
|
|
||||||
declare module 'vue/types/vue' {
|
declare module 'vue/types/vue' {
|
||||||
interface Vue {
|
interface Vue {
|
||||||
|
$config: NuxtRuntimeConfig
|
||||||
$nuxt: NuxtApp
|
$nuxt: NuxtApp
|
||||||
$fetch(): void
|
$fetch(): void
|
||||||
$fetchState: {
|
$fetchState: {
|
||||||
|
3
packages/types/config/index.d.ts
vendored
3
packages/types/config/index.d.ts
vendored
@ -13,6 +13,7 @@ import { NuxtOptionsModule } from './module'
|
|||||||
import { NuxtOptionsPlugin } from './plugin'
|
import { NuxtOptionsPlugin } from './plugin'
|
||||||
import { NuxtOptionsRender } from './render'
|
import { NuxtOptionsRender } from './render'
|
||||||
import { NuxtOptionsRouter } from './router'
|
import { NuxtOptionsRouter } from './router'
|
||||||
|
import { NuxtConfigurationRuntimeConfig } from './runtime'
|
||||||
import { NuxtOptionsServer } from './server'
|
import { NuxtOptionsServer } from './server'
|
||||||
import { NuxtOptionsServerMiddleware } from './server-middleware'
|
import { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||||
import { NuxtOptionsVueConfiguration } from './vue-configuration'
|
import { NuxtOptionsVueConfiguration } from './vue-configuration'
|
||||||
@ -50,6 +51,8 @@ export interface NuxtOptions extends Record<string, any> {
|
|||||||
modules: NuxtOptionsModule[]
|
modules: NuxtOptionsModule[]
|
||||||
modulesDir: string[]
|
modulesDir: string[]
|
||||||
plugins: NuxtOptionsPlugin[]
|
plugins: NuxtOptionsPlugin[]
|
||||||
|
privateRuntimeConfig?: NuxtConfigurationRuntimeConfig
|
||||||
|
publicRuntimeConfig?: NuxtConfigurationRuntimeConfig
|
||||||
render: NuxtOptionsRender
|
render: NuxtOptionsRender
|
||||||
rootDir: string
|
rootDir: string
|
||||||
router: NuxtOptionsRouter
|
router: NuxtOptionsRouter
|
||||||
|
10
packages/types/config/runtime.d.ts
vendored
Normal file
10
packages/types/config/runtime.d.ts
vendored
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user