Skip to content

1.21.0

Compare
Choose a tag to compare
@whxaxes whxaxes released this 01 Feb 16:15
· 120 commits to master since this release

Auto create d.ts to create a global namespace: Egg, so the types can be used without import.

The created d.ts is

// typings/app/index.d.ts
export * from 'egg';
export as namespace Egg;

In js project, we can use Egg.Application instead of import('egg').Application.

/**
 * @param {Egg.Application} app
 */
module.exports = app => {
  const { router, controller } = app;
  router.get('/', app.middleware.access, controller.home.index);
}

In ts project, we can use Egg.Application and no need to import Application from egg.

export default (app: Egg.Application) => {
  const { router, controller } = app;
  router.get('/', app.middleware.access, controller.home.index);
}