Reputation: 28128
I have included a Typescript definition file so that I can program my very basic node express server in Typescript. I have installed the types using:
npm install @types/node --save-dev
Sadly, my IDE (VS Code) still doesn't recognise the Node typings:
server.ts
import * as express from "express";
const app = express();
app.get('/', (req, res) => {
res.send('Hello Typescript!')
});
const server = app.listen(3000, () => {
console.log("listening on port 3000")
})
errors
app.get Property 'get' does not exist on type 'Function'
app.listen Property 'listen' does not exist on type 'Function'
Upvotes: 1
Views: 2283
Reputation: 121
You will also need types for Express:
npm install @types/express --save-dev
Upvotes: 4