Using Express() with TypeScript
Pretty old discussion, but I ran into the same problem recently and found that there is a new express.d.ts
that properly supports express 3 on the DefinitelyTyped site.
You should be able to add this ambient function declaration to express.d.ts
to get what you want.
declare function express(): ExpressServer;
if you declare express
this way: import * as express from "express"
, you will get this error in runtime, declaring it this way: const express = require "express"
, won't throw any error.
Also, don't forget to declare app
variable or property type as express.Application