From 949e556f0ed71ea273e20f236b80748831e8b338 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Thu, 2 May 2024 10:17:28 +0200 Subject: [PATCH] fix(types): export `ModulePublicRuntimeConfig` for module builder type generation (#738) --- src/module.ts | 14 ++++++++++++++ src/runtime/types.ts | 7 ------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/module.ts b/src/module.ts index 9202584f..e3f20ada 100644 --- a/src/module.ts +++ b/src/module.ts @@ -16,6 +16,7 @@ import type { NuxtModule } from 'nuxt/schema' import { getOriginAndPathnameFromURL, isProduction } from './runtime/helpers' import type { ModuleOptions, + ModuleOptionsNormalized, SupportedAuthProviders, AuthProviders } from './runtime/types' @@ -246,3 +247,16 @@ export default defineNuxtModule({ logger.success('`nuxt-auth` setup done') } }) satisfies NuxtModule + +// Used by nuxt/module-builder for `types.d.ts` generation +export type { ModuleOptions } +export interface ModulePublicRuntimeConfig { + auth: ModuleOptionsNormalized +} + +// Augment types for type inference in source code +declare module '@nuxt/schema' { + interface PublicRuntimeConfig { + auth: ModuleOptionsNormalized + } +} diff --git a/src/runtime/types.ts b/src/runtime/types.ts index 9b16b720..00c96fa8 100644 --- a/src/runtime/types.ts +++ b/src/runtime/types.ts @@ -514,10 +514,3 @@ export interface ModuleOptionsNormalized extends ModuleOptions { fullBaseUrl: string } } - -// Augment types -declare module 'nuxt/schema' { - interface PublicRuntimeConfig { - auth: ModuleOptionsNormalized - } -}