Skip to content

Commit

Permalink
feat(types): add basic types for Nuxt interface (#9772)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 14, 2023
1 parent 7ecb003 commit c493723
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/types/config/module.d.ts
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions 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
}

0 comments on commit c493723

Please sign in to comment.