Skip to content

Commit 25c6528

Browse files
committed
export EggAppInfo
1 parent 8e1a12e commit 25c6528

5 files changed

Lines changed: 20 additions & 24 deletions

File tree

index-old.d.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -218,30 +218,6 @@
218218

219219
// export type LoggerLevel = EggLoggerLevel;
220220

221-
222-
// /**
223-
// * egg app info
224-
// * @example
225-
// * ```js
226-
// * // config/config.default.ts
227-
// * import { EggAppInfo } from 'egg';
228-
// *
229-
// * export default (appInfo: EggAppInfo) => {
230-
// * return {
231-
// * keys: appInfo.name + '123456',
232-
// * };
233-
// * }
234-
// * ```
235-
// */
236-
// export interface EggAppInfo {
237-
// pkg: any; // package.json
238-
// name: string; // the application name from package.json
239-
// baseDir: string; // current directory of application
240-
// env: EggEnvType; // equals to serverEnv
241-
// HOME: string; // home directory of the OS
242-
// root: string; // baseDir when local and unittest, HOME when other environment
243-
// }
244-
245221
// type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
246222
// type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
247223

src/app/extend/request.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const HOST = Symbol('request host');
1111
const IPS = Symbol('request ips');
1212
const RE_ARRAY_KEY = /[^\[\]]+\[\]$/;
1313

14+
import './request.types.js';
15+
1416
export default class Request extends EggCoreRequest {
1517
declare app: Application;
1618
declare ctx: Context;

src/app/extend/response.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Response as KoaResponse } from '@eggjs/core';
22

33
const REAL_STATUS = Symbol('response realStatus');
44

5+
import './response.types.js';
6+
57
export default class Response extends KoaResponse {
68
/**
79
* Get or set a real status code.

src/lib/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.js';
1818
// import @eggjs/watcher types
1919
// import '@eggjs/watcher';
2020

21+
export type {
22+
EggAppInfo,
23+
} from '@eggjs/core';
24+
25+
2126
type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
2227
type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
2328

test/index.test-d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Context, Application, IBoot, ILifecycleBoot,
44
LoggerLevel,
55
EggPlugin,
6+
EggAppInfo,
67
} from '../src/index.js';
78
import { HttpClient } from '../src/urllib.js';
89

@@ -98,3 +99,13 @@ const plugin: EggPlugin = {
9899
logrotator: true,
99100
};
100101
expectType<EggPlugin>(plugin);
102+
103+
expectType<EggAppInfo>({
104+
name: 'egg',
105+
baseDir: 'baseDir',
106+
env: 'env',
107+
HOME: 'HOME',
108+
pkg: {},
109+
scope: 'scope',
110+
root: 'root',
111+
});

0 commit comments

Comments
 (0)