Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Feb 3, 2025
1 parent 77b3d80 commit 8738955
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 21 deletions.
15 changes: 0 additions & 15 deletions index-old.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
// BaseContextClass as CoreBaseContextClass,
// } from 'egg-core';
// import EggCookies = require('egg-cookies');
// import 'egg-view';

// declare module 'egg' {
// export type EggLogger = Logger;
Expand Down Expand Up @@ -1042,20 +1041,6 @@

// export function start(options?: StartOptions): Promise<Application>;

// /**
// * Powerful Partial, Support adding ? modifier to a mapped property in deep level
// * @example
// * import { PowerPartial, EggAppConfig } from 'egg';
// *
// * // { view: { defaultEngines: string } } => { view?: { defaultEngines?: string } }
// * type EggConfig = PowerPartial<EggAppConfig>
// */
// export type PowerPartial<T> = {
// [U in keyof T]?: T[U] extends object
// ? PowerPartial<T[U]>
// : T[U]
// };

// // send data can be number|string|boolean|object but not Set|Map
// export interface Messenger extends EventEmitter {
// /**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"@eggjs/session": "^4.0.1",
"@eggjs/static": "^3.0.0",
"@eggjs/utils": "^4.2.5",
"@eggjs/view": "^3.0.1",
"@eggjs/watcher": "^4.0.4",
"circular-json-for-egg": "^1.0.0",
"cluster-client": "^3.7.0",
"egg-errors": "^2.3.2",
"egg-logger": "^3.6.1",
"egg-view": "^2.1.4",
"extend2": "^4.0.0",
"graceful": "^2.0.0",
"humanize-ms": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions site/docs/advanced/view-plugin.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ order: 5
本文将阐述框架对 View 插件的规范约束。我们可以依此来封装对应的模板引擎插件。以下以 [egg-view-ejs](https://github.com/eggjs/egg-view-ejs) 为例。

## 插件目录结构

```bash
egg-view-ejs
├── config
Expand Down
2 changes: 1 addition & 1 deletion site/docs/core/view.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ The built-in plugin [@eggjs/security] provides common security helper functions,

[@eggjs/security]: https://github.com/eggjs/security
[egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks
[egg-view]: https://github.com/eggjs/egg-view
[egg-view]: https://github.com/eggjs/view
2 changes: 1 addition & 1 deletion site/docs/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Official maintained ORM model is [egg-orm] base on [Leoric], and the following d
[egg-sequelize]: https://github.com/eggjs/egg-sequelize
[egg-mongoose]: https://github.com/eggjs/egg-mongoose
[egg-mysql]: https://github.com/eggjs/egg-mysql
[egg-view]: https://github.com/eggjs/egg-view
[egg-view]: https://github.com/eggjs/view
[egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks
[egg-view-ejs]: https://github.com/eggjs/egg-view-ejs
[egg-view-handlebars]: https://github.com/eggjs/egg-view-handlebars
Expand Down
2 changes: 1 addition & 1 deletion site/docs/tutorials/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ npm init egg --type=simple
[egg-sequelize]: https://github.com/eggjs/egg-sequelize
[egg-mongoose]: https://github.com/eggjs/egg-mongoose
[egg-mysql]: https://github.com/eggjs/egg-mysql
[egg-view]: https://github.com/eggjs/egg-view
[egg-view]: https://github.com/eggjs/view
[egg-view-nunjucks]: https://github.com/eggjs/egg-view-nunjucks
[egg-view-ejs]: https://github.com/eggjs/egg-view-ejs
[egg-view-handlebars]: https://github.com/eggjs/egg-view-handlebars
Expand Down
3 changes: 2 additions & 1 deletion site/docs/tutorials/typescript.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,9 @@ describe('typescript', () => {
以下几个项目可作为单元测试参考:

- [https://github.com/eggjs/egg](https://github.com/eggjs/egg)
- [https://github.com/eggjs/egg-view](https://github.com/eggjs/egg-view)
- [https://github.com/eggjs/view](https://github.com/eggjs/view)
- [https://github.com/eggjs/egg-logger](https://github.com/eggjs/egg-logger)

### 编译速度慢?

根据我们的实践,`ts-node` 是目前相对较优的解决方案,既不用另起终端执行 `tsc`,也能获得还能接受的启动速度(仅限于 `ts-node@7`,新的版本由于把文件缓存去掉了,导致特别慢([#754](https://github.com/TypeStrong/ts-node/issues/754)),因此未升级)。
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ export default {
*/
view: {
enable: true,
package: 'egg-view',
package: '@eggjs/view',
},
};
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import '@eggjs/session';
import '@eggjs/onerror';
import '@eggjs/logrotator';
import '@eggjs/multipart';
import '@eggjs/view';

export type {
EggAppInfo,
Expand Down
9 changes: 9 additions & 0 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ expectType<string>(app.config.multipart.cleanSchedule.cron);
expectType<string>(app.config.multipart.defaultCharset);
expectType<'file' | 'stream'>(app.config.multipart.mode);

// view plugin types
expectType<string>(app.config.view.defaultViewEngine);
expectType<string>(app.config.view.root);
expectType<string>(app.config.view.mapping.html);
expectType<string>(app.config.view.defaultExtension);
expectType<string>(await ctx.renderString('hello'));
expectType<string>(await ctx.view.renderString('hello'));
const ViewEngine = app.view.get('html')!;
expectType<string>(await new ViewEngine(ctx).render('hello'));

class AppBoot implements ILifecycleBoot {
private readonly app: Application;
Expand Down

0 comments on commit 8738955

Please sign in to comment.