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 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<string, any>
|
||||
|
||||
export interface Context {
|
||||
$config: NuxtRuntimeConfig
|
||||
|
||||
app: NuxtAppOptions
|
||||
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
|
||||
*/
|
||||
|
||||
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<V extends Vue> {
|
||||
@ -28,6 +29,7 @@ declare module 'vue/types/options' {
|
||||
|
||||
declare module 'vue/types/vue' {
|
||||
interface Vue {
|
||||
$config: NuxtRuntimeConfig
|
||||
$nuxt: NuxtApp
|
||||
$fetch(): void
|
||||
$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 { 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<string, any> {
|
||||
modules: NuxtOptionsModule[]
|
||||
modulesDir: string[]
|
||||
plugins: NuxtOptionsPlugin[]
|
||||
privateRuntimeConfig?: NuxtConfigurationRuntimeConfig
|
||||
publicRuntimeConfig?: NuxtConfigurationRuntimeConfig
|
||||
render: NuxtOptionsRender
|
||||
rootDir: string
|
||||
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