1.21.0
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);
}