I have a node server running on express and I am looking to add metrics to it during the setup process. Here is a snippet of my code:
const app = express();
installMetrics(app);
While TypeScript can accurately determine the type of app
since I have installed @types/express
, I am unsure how to properly type the parameter app
in my installMetrics function. If I attempt to specify app: Express
, I receive an error: "Cannot use namespace 'Express' as a type". I have also considered creating a new type to mimic the usage, but that seems overly complex and not worth the added effort/clutter.
Although I dislike the idea, it appears that using any
may be my best option. I have explored other solutions, such as
declare type TExpress = typeof import("express")
, but it did not provide the correct type (as the import would need to be called to return the accurate type). Am I overlooking something, or is this a issue that I will just have to find a workaround for?