Searching through numerous examples of ExpressJS and TypeScript, I noticed they all follow a similar pattern:
import * as express from "express";
let app = express();
app.use("/", express.static("/"));
However, my preference is to employ the class approach instead:
import * as express from "express";
export class ServerApp {
private app: express.Express = express();
public configure {
this.app.use('/', express.static("/");
}
}
Encountering an argument type warning when trying to access the use
method on the private variable was not ideal.
I strive for strong typing, making private app: any
an inadequate solution. Is there a way to address this issue effectively, or perhaps a superior alternative exist?