Skip to content

Commit

Permalink
fix watcher types
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 4, 2025
1 parent 1aac19f commit 193319d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "egg",
"version": "4.0.0-beta.14",
"version": "4.0.0-beta.15",
"engines": {
"node": ">= 18.19.0"
},
Expand All @@ -21,10 +21,10 @@
"dependencies": {
"@eggjs/cluster": "^3.0.0",
"@eggjs/cookies": "^3.0.0",
"@eggjs/core": "^6.2.11",
"@eggjs/core": "^6.2.13",
"@eggjs/schedule": "^5.0.2",
"@eggjs/utils": "^4.1.5",
"@eggjs/watcher": "^4.0.1",
"@eggjs/utils": "^4.2.4",
"@eggjs/watcher": "^4.0.3",
"circular-json-for-egg": "^1.0.0",
"cluster-client": "^3.7.0",
"egg-development": "^3.0.0",
Expand Down
73 changes: 36 additions & 37 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
} from 'egg-logger';
import type {
FileLoaderOptions,
EggAppConfig as EggCoreAppConfig,
} from '@eggjs/core';
import type {
EggApplicationCore, Context,
Expand All @@ -16,7 +17,7 @@ import type { NotFoundMiddlewareOptions } from '../app/middleware/notfound.js';
import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.js';

// import @eggjs/watcher types
// import '@eggjs/watcher';
import '@eggjs/watcher';

export type {
EggAppInfo,
Expand Down Expand Up @@ -61,7 +62,7 @@ export interface CustomLoaderConfig extends Omit<FileLoaderOptions, 'inject' | '
loadunit?: boolean;
}

export interface EggAppConfig {
export interface EggAppConfig extends EggCoreAppConfig {
workerStartTimeout: number;
baseDir: string;
middleware: string[];
Expand Down Expand Up @@ -147,43 +148,43 @@ export interface EggAppConfig {
useHttpClientNext?: boolean;
};

development: {
/**
* dirs needed watch, when files under these change, application will reload, use relative path
*/
watchDirs: string[];
/**
* dirs don't need watch, including subdirectories, use relative path
*/
ignoreDirs: string[];
/**
* don't wait all plugins ready, default is true.
*/
fastReady: boolean;
/**
* whether reload on debug, default is true.
*/
reloadOnDebug: boolean;
/**
* whether override default watchDirs, default is false.
*/
overrideDefault: boolean;
/**
* whether override default ignoreDirs, default is false.
*/
overrideIgnore: boolean;
/**
* whether to reload, use https://github.com/sindresorhus/multimatch
*/
reloadPattern: string[] | string;
};
// development: {
// /**
// * dirs needed watch, when files under these change, application will reload, use relative path
// */
// watchDirs: string[];
// /**
// * dirs don't need watch, including subdirectories, use relative path
// */
// ignoreDirs: string[];
// /**
// * don't wait all plugins ready, default is true.
// */
// fastReady: boolean;
// /**
// * whether reload on debug, default is true.
// */
// reloadOnDebug: boolean;
// /**
// * whether override default watchDirs, default is false.
// */
// overrideDefault: boolean;
// /**
// * whether override default ignoreDirs, default is false.
// */
// overrideIgnore: boolean;
// /**
// * whether to reload, use https://github.com/sindresorhus/multimatch
// */
// reloadPattern: string[] | string;
// };

/**
* customLoader config
*/
customLoader: {
[key: string]: CustomLoaderConfig;
};
// customLoader: {
// [key: string]: CustomLoaderConfig;
// };

/**
* It will ignore special keys when dumpConfig
Expand Down Expand Up @@ -308,8 +309,6 @@ export interface EggAppConfig {
allowedMethods: string[];
};

watcher: Record<string, any>;

onClientError?(err: Error, socket: Socket, app: EggApplicationCore): ClientErrorResponse | Promise<ClientErrorResponse>;

/**
Expand Down
1 change: 0 additions & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import path from 'node:path';
import { fileURLToPath } from 'node:url';

Expand Down
4 changes: 4 additions & 0 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ expectType<Context>(ctx);
expectType<HttpClient>(ctx.httpClient);
expectType<any>(ctx.request.body);

expectType<object>(app.watcher);
expectType<string>(app.config.watcher.type);
expectType<string>(app.config.watcher.eventSources.default);

class AppBoot implements ILifecycleBoot {
private readonly app: Application;

Expand Down

0 comments on commit 193319d

Please sign in to comment.