diff --git a/packages/bridge/types.d.ts b/packages/bridge/types.d.ts index 730bdb71a0..f36d009cca 100644 --- a/packages/bridge/types.d.ts +++ b/packages/bridge/types.d.ts @@ -1,3 +1,4 @@ +import type {} from '@nuxt/nitro' import type { NuxtConfig as _NuxtConfig } from '@nuxt/kit' export interface BridgeConfig { diff --git a/packages/nuxi/src/commands/prepare.ts b/packages/nuxi/src/commands/prepare.ts index a6c21e1396..789aa7d0f4 100644 --- a/packages/nuxi/src/commands/prepare.ts +++ b/packages/nuxi/src/commands/prepare.ts @@ -1,7 +1,7 @@ import { promises as fsp } from 'fs' import { relative, resolve } from 'pathe' import { cyan } from 'colorette' -import { isNuxt3, TSReference } from '@nuxt/kit' +import { TSReference } from '@nuxt/kit' import { importModule, getModulePaths, getNearestPackage } from '../utils/cjs' import { success } from '../utils/log' import { defineNuxtCommand } from './index' @@ -19,15 +19,9 @@ export default defineNuxtCommand({ const { loadNuxt } = await importModule('@nuxt/kit', rootDir) as typeof import('@nuxt/kit') const nuxt = await loadNuxt({ rootDir }) - const adHocModules = isNuxt3() - ? ['@nuxt/kit', '@nuxt/nitro'] - : ['@nuxt/kit'] - const modulePaths = getModulePaths(nuxt.options.modulesDir) const references: TSReference[] = [ - ...isNuxt3() ? ['nuxt3'] : [], - ...adHocModules, ...nuxt.options.buildModules, ...nuxt.options.modules, ...nuxt.options._modules diff --git a/packages/nuxt3/src/core/nuxt.ts b/packages/nuxt3/src/core/nuxt.ts index 96fb9dfa9e..6cdbb3a1f8 100644 --- a/packages/nuxt3/src/core/nuxt.ts +++ b/packages/nuxt3/src/core/nuxt.ts @@ -39,6 +39,11 @@ async function initNuxt (nuxt: Nuxt) { // Init nitro await initNitro(nuxt) + // Add nuxt3 types + nuxt.hook('prepare:types', (opts) => { + opts.references.push({ types: 'nuxt3' }) + }) + // Init user modules await nuxt.callHook('modules:before', { nuxt } as ModuleContainer) const modulesToInstall = [ diff --git a/packages/nuxt3/types.d.ts b/packages/nuxt3/types.d.ts index a04fb2af62..8ac0948ccc 100644 --- a/packages/nuxt3/types.d.ts +++ b/packages/nuxt3/types.d.ts @@ -1,2 +1,3 @@ +import type { } from '@nuxt/nitro' export * from './dist/index' export * from './dist/app/types/index' diff --git a/playground/nuxt.d.ts b/playground/nuxt.d.ts index 7f195695f2..c6ef6c86ba 100644 --- a/playground/nuxt.d.ts +++ b/playground/nuxt.d.ts @@ -2,8 +2,6 @@ // Please do not manually modify this file. /// -/// -/// /// /// export {}