@@ -53,7 +53,7 @@ export interface PluginInfo {
5353
5454export interface Plugins extends PlainObject < PluginInfo > { }
5555
56- export class EggCore < Config = PlainObject > extends KoaApplication {
56+ export interface EggCoreBase < Config > extends KoaApplication {
5757 /**
5858 * Whether `application` or `agent`
5959 * @member {String}
@@ -77,16 +77,6 @@ export class EggCore<Config = PlainObject> extends KoaApplication {
7777 */
7878 name : EggAppInfo [ 'name' ] ;
7979
80- /**
81- * @constructor
82- * @param {Object } options - options
83- * @param {String } [options.baseDir=process.cwd()] - the directory of application
84- * @param {String } [options.type=application|agent] - whether it's running in app worker or agent worker
85- * @param {Object } [options.plugins] - custom plugins
86- * @since 1.0.0
87- */
88- constructor ( options ?: EggCoreOptions ) ;
89-
9080 /**
9181 * Convert a generator function to a promisable one.
9282 *
@@ -207,11 +197,25 @@ export class EggCore<Config = PlainObject> extends KoaApplication {
207197 * @since 1.0.0
208198 */
209199 deprecate : depd . Deprecate ;
200+ }
210201
202+ export interface EggCore < Config = PlainObject > extends EggCoreBase < Config > {
211203 Controller : typeof BaseContextClass ;
212204 Service : typeof BaseContextClass ;
213205}
214206
207+ export class EggCore {
208+ /**
209+ * @constructor
210+ * @param {Object } options - options
211+ * @param {String } [options.baseDir=process.cwd()] - the directory of application
212+ * @param {String } [options.type=application|agent] - whether it's running in app worker or agent worker
213+ * @param {Object } [options.plugins] - custom plugins
214+ * @since 1.0.0
215+ */
216+ constructor ( options ?: EggCoreOptions ) ;
217+ }
218+
215219/**
216220 * egg app info
217221 * @example
@@ -301,13 +305,7 @@ export interface ContextLoaderOption extends Partial<FileLoaderOption> {
301305 fieldClass ?: string ;
302306}
303307
304- declare class FileLoader {
305- /**
306- * Load files from directory to target object.
307- * @since 1.0.0
308- */
309- constructor ( options : FileLoaderOption ) ;
310-
308+ declare interface FileLoaderBase {
311309 /**
312310 * attach items to target object. Mapping the directory to properties.
313311 * `app/controller/group/repository.js` => `target.group.repository`
@@ -345,13 +343,23 @@ declare class FileLoader {
345343 parse ( ) : Array < { fullpath : string ; properties : string [ ] ; exports : any ; } > ;
346344}
347345
348- declare class ContextLoader extends FileLoader {
346+ declare interface ContextLoaderBase extends FileLoaderBase { }
347+
348+ export interface FileLoader {
349+ /**
350+ * Load files from directory to target object.
351+ * @since 1.0.0
352+ */
353+ new ( options : FileLoaderOption ) : FileLoaderBase ;
354+ }
355+
356+ export interface ContextLoader {
349357 /**
350358 * Same as {@link FileLoader}, but it will attach file to `inject[fieldClass]`. The exports will be lazy loaded, such as `ctx.group.repository`.
351359 * @extends FileLoader
352360 * @since 1.0.0
353361 */
354- constructor ( options : ContextLoaderOption ) ;
362+ new ( options : ContextLoaderOption ) : ContextLoaderBase ;
355363}
356364
357365export class EggLoader < T = EggCore , Config = any > {
@@ -442,8 +450,8 @@ export class EggLoader<T = EggCore, Config = any> {
442450 getTypeFiles ( filename : string ) : string [ ] ;
443451 resolveModule ( filepath : string ) : string | undefined ;
444452
445- FileLoader : typeof FileLoader ;
446- ContextLoader : typeof ContextLoader ;
453+ FileLoader : FileLoader ;
454+ ContextLoader : ContextLoader ;
447455
448456 // load methods
449457 protected loadConfig ( ) : void ;
0 commit comments