0

I have a module in typescript which contains the following code.

export class Account {
constructor(app: any) {
    this.initialize(app);
  }

private initialize(app: any) {
    app.get("/login", (req: any, res: any) => {
        res.render("index", { user: req.user });
    });

    app.get("/logout", (req: any, res: any) => {
        res.render("index", { user: req.user });
    });
}

}

And I want to load this module in main file. like

require('/mymodule')(app)

How I can do this in typescript ?

Deepak
  • 1,510
  • 1
  • 14
  • 27

1 Answers1

1

require('/mymodule')(app)

Proper way:

import {Account} from './mymodule';
new Account(app);

More

Just some free docs

basarat
  • 261,912
  • 58
  • 460
  • 511
  • Thanks @basarat for answering, I am already using the same approach but as per the tslint rule it's an unused-expression. – Deepak May 18 '17 at 06:06