Skip to content

Commit 8fa4aec

Browse files
authored
fix: add missing tsd on application (#5406)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated a development dependency to its latest minor release for improved stability. - **New Features** - Enhanced server operations with improved error handling and background processing capabilities, offering richer configuration support. - **Tests** - Refined configuration validations to strengthen testing reliability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1d5031e commit 8fa4aec

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@arethetypeswrong/cli": "^0.17.3",
5656
"@eggjs/bin": "^7.0.2",
5757
"@eggjs/koa": "^2.20.6",
58-
"@eggjs/mock": "^6.0.6",
58+
"@eggjs/mock": "^6.0.7",
5959
"@eggjs/supertest": "^8.2.0",
6060
"@eggjs/tsconfig": "1",
6161
"@types/koa-bodyparser": "^4.3.12",

src/lib/application.ts

+12
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,15 @@ export class Application extends EggApplicationCore {
294294
}
295295
}
296296

297+
declare module '@eggjs/core' {
298+
// add EggApplicationCore overrides types
299+
interface EggCore {
300+
onClientError(err: any, socket: Socket): void;
301+
onServer(server: http.Server): void;
302+
locals: Record<string, any>;
303+
runInBackground(scope: (ctx: Context) => Promise<void>, req?: unknown): void;
304+
toAsyncFunction(fn: (...args: any[]) => any): (...args: any[]) => any;
305+
dumpConfig(): void;
306+
get keys(): string[];
307+
}
308+
}

test/index.test-d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
start, SingleModeApplication, SingleModeAgent,
1010
MiddlewareFunc,
1111
Singleton,
12+
PowerPartial,
13+
EggAppConfig,
1214
} from '../src/index.js';
1315
import { HttpClient } from '../src/urllib.js';
1416
import { IMessenger } from '../src/lib/core/messenger/IMessenger.js';
@@ -18,6 +20,9 @@ expectType<IMessenger>(app.messenger);
1820
expectType<IMessenger>(app.messenger.broadcast('test'));
1921
expectType<void>(app.loggers.reload());
2022

23+
const config = {} as PowerPartial<EggAppConfig>;
24+
expectType<boolean | undefined>(config.static?.gzip);
25+
2126
const ctx = app.createAnonymousContext();
2227

2328
expectType<Promise<void>>(app.runInAnonymousContextScope(async ctx => {

0 commit comments

Comments
 (0)