From 8e4905c2fe4531f27aeb45b1b06d2fc03868e2a3 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 18 Jan 2024 10:04:59 +0000 Subject: [PATCH] fix(nuxt): add declaration file with correct node16 imports (#25266) --- packages/nuxt/package.json | 3 ++- packages/nuxt/src/app/nuxt.ts | 2 +- packages/nuxt/types.d.mts | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 packages/nuxt/types.d.mts diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 5d35c0816c..e9200effba 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -17,7 +17,7 @@ }, "exports": { ".": { - "types": "./types.d.ts", + "types": "./types.d.mts", "import": "./dist/index.mjs" }, "./config": { @@ -49,6 +49,7 @@ "app.d.ts", "bin", "types.d.ts", + "types.d.mts", "dist", "config.*", "kit.*", diff --git a/packages/nuxt/src/app/nuxt.ts b/packages/nuxt/src/app/nuxt.ts index 553faaf95c..93d623cf24 100644 --- a/packages/nuxt/src/app/nuxt.ts +++ b/packages/nuxt/src/app/nuxt.ts @@ -17,7 +17,7 @@ import type { RouteMiddleware } from '../app/composables/router' import type { NuxtError } from '../app/composables/error' import type { AsyncDataRequestStatus } from '../app/composables/asyncData' import type { NuxtAppManifestMeta } from '../app/composables/manifest' -import type { LoadingIndicator } from '#app/composables/loading-indicator' +import type { LoadingIndicator } from '../app/composables/loading-indicator' import type { NuxtAppLiterals } from '#app' diff --git a/packages/nuxt/types.d.mts b/packages/nuxt/types.d.mts new file mode 100644 index 0000000000..210e33bd5c --- /dev/null +++ b/packages/nuxt/types.d.mts @@ -0,0 +1,33 @@ +/// +export * from './dist/index.js' + +import type { DefineNuxtConfig } from 'nuxt/config' +import type { RuntimeConfig, SchemaDefinition } from 'nuxt/schema' +import type { H3Event } from 'h3' +import type { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from './dist/core/runtime/nitro/renderer.js' + +declare global { + const defineNuxtConfig: DefineNuxtConfig + const defineNuxtSchema: (schema: SchemaDefinition) => SchemaDefinition +} + +// Note: Keep in sync with packages/nuxt/src/core/templates.ts +declare module 'nitropack' { + interface NitroRuntimeConfigApp { + buildAssetsDir: string + cdnURL: string + } + interface NitroRuntimeConfig extends RuntimeConfig {} + interface NitroRouteConfig { + ssr?: boolean + experimentalNoScripts?: boolean + } + interface NitroRouteRules { + ssr?: boolean + experimentalNoScripts?: boolean + } + interface NitroRuntimeHooks { + 'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise + 'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise + } +}