feat(types): add basic types for Nuxt interface (#9772)

This commit is contained in:
pooya parsa 2023-02-14 12:59:54 +01:00 committed by GitHub
parent 7ecb003c7f
commit c493723437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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<any>
options: NuxtOptions
nuxt: any // TBD
[key: string]: any // TBD
nuxt: Nuxt
[key: string]: any
}
export type Module<T = any> = (this: ModuleThis, moduleOptions: T) => Promise<void> | void

16
packages/types/nuxt.d.ts vendored Normal file
View File

@ -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
}