1
votes

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'

1

1 Answers

3
votes

You will also need types for Express:

npm install @types/express --save-dev