How do I pass arguments while loading any modules in typescript?

203 views Asked by At

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 ?

1

There are 1 answers

1
basarat On

require('/mymodule')(app)

Proper way:

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

More

Just some free docs