From c4937234374664d5f587dc0da97a425acdb7e7e4 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Tue, 14 Feb 2023 12:59:54 +0100 Subject: [PATCH] feat(types): add basic types for Nuxt interface (#9772) --- packages/types/config/module.d.ts | 5 +++-- packages/types/nuxt.d.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 packages/types/nuxt.d.ts diff --git a/packages/types/config/module.d.ts b/packages/types/config/module.d.ts index f7cc3565fe..92f21c8059 100644 --- a/packages/types/config/module.d.ts +++ b/packages/types/config/module.d.ts @@ -5,6 +5,7 @@ */ import type { Configuration as WebpackConfiguration } from 'webpack' +import type { Nuxt } from '../nuxt' import type { NuxtOptionsLoaders } from './build' import type { NuxtRouteConfig } from './router' import type { NuxtOptionsServerMiddleware } from './server-middleware' @@ -57,8 +58,8 @@ interface ModuleThis { // eslint-disable-next-line no-use-before-define addModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise options: NuxtOptions - nuxt: any // TBD - [key: string]: any // TBD + nuxt: Nuxt + [key: string]: any } export type Module = (this: ModuleThis, moduleOptions: T) => Promise | void diff --git a/packages/types/nuxt.d.ts b/packages/types/nuxt.d.ts new file mode 100644 index 0000000000..2cec0b1dc6 --- /dev/null +++ b/packages/types/nuxt.d.ts @@ -0,0 +1,16 @@ +import type { RequestListener } from 'http' +import type { NuxtOptions } from './config' + +export interface Nuxt { + options: NuxtOptions, + server: { app: RequestListener }, + ready: () => any + close: (callback?: Function) => any + resolver: any + moduleContainer: any + resolveAlias(path: string): string + resolvePath(path: string, opts?: any): string + renderRoute(...args: any[]): any + renderAndGetWindow(url: string, opts?: any, config?: any): any + [key: string]: any +}