Reputation: 355
I read this post, and this one, and figured it is probably not a good idea to use default export. However, when I was trying to change my code, I ran to an issue: there some variables/objects/functions are not clearly defined to be export. For example:
import * as express from 'express';
import { Controller } from './controller';
const controller = new Controller();
express.Router()
.post('/', controller.create)
.get('/', controller.all)
.get('/:id', controller.byId);
export default express.Router();
I wonder how can I declare the export so it won't use the default export. I tried
export = express.Router
But I feel that is not a good practice as well. Any ideas?
Upvotes: 1
Views: 141
Reputation: 3322
Default exports are not bad if you use them right. In this example it is totally fine.
But if you want to give it a name, just assign it to a variable.
export const router = express.Router();
Upvotes: 2