diff --git a/docs/content/en/helpers/definitionHelpers.md b/docs/content/en/typings/definitionHelpers.md similarity index 67% rename from docs/content/en/helpers/definitionHelpers.md rename to docs/content/en/typings/definitionHelpers.md index 3b1e891c..9a962454 100644 --- a/docs/content/en/helpers/definitionHelpers.md +++ b/docs/content/en/typings/definitionHelpers.md @@ -1,13 +1,27 @@ --- -title: Definition helpers -description: '@nuxtjs/composition-api provides a way to use the Vue 3 Composition API with Nuxt-specific features.' -category: Helpers +title: defineNuxt* +description: 'You can get automatic type-hinting for Nuxt configuration, plugins, middleware, modules and serverMiddleware.' +category: Typings position: 10 +version: 0.192 + --- There are some helpers to optimize developer experience when creating Nuxt plugins, middleware, server middleware and modules. -These helpers simply return the function passed into them, adding the correct typings. +These helpers simply return the function or object passed into them, adding the correct typings. + +## defineNuxtConfig + +Create your `nuxt.config.js` with types with: + +```ts +import { defineNuxtConfig } from '@nuxtjs/composition-api' + +export default defineNuxtConfig({ + // your nuxt config +}) +``` ## defineNuxtPlugin @@ -57,4 +71,3 @@ export default defineNuxtServerMiddleware((req, res, next) => { // do stuff }) ``` - diff --git a/src/defineHelpers.ts b/src/defineHelpers.ts index 6ca192c8..b39501f5 100644 --- a/src/defineHelpers.ts +++ b/src/defineHelpers.ts @@ -1,4 +1,10 @@ -import { Middleware, Plugin, Module, ServerMiddleware } from '@nuxt/types' +import { + Middleware, + Plugin, + Module, + ServerMiddleware, + NuxtConfig, +} from '@nuxt/types' export const defineNuxtPlugin = (plugin: Plugin) => plugin export const defineNuxtMiddleware = (middleware: Middleware) => middleware @@ -8,3 +14,4 @@ export const defineNuxtModule = >( export const defineNuxtServerMiddleware = ( serverMiddleware: ServerMiddleware ) => serverMiddleware +export const defineNuxtConfig = (config: NuxtConfig) => config