pixelpax
pixelpax

Reputation: 1517

Display errors with source mapping (typescript + node/express)

I have a node instance in a docker container running express.

When I throw an error in my (extremely basic) app.ts

// Prepare to receive requests
app.listen(3000, () => {
  console.log('Application Service starting!');
  throw Error('foo');
});

I get

application-service_1  | Application Service starting!
application-service_1  | /app/js/server.js:19
application-service_1  |     throw Error('foo');
application-service_1  |     ^

I want to be able to see errors from the typescript code, and not from the derived js code.

Has anyone made errorhandler middleware which could allow me to do this?

Or is there a better way to set this up?

Upvotes: 3

Views: 87

Answers (1)

pixelpax
pixelpax

Reputation: 1517

So, one solution I've now found is to just use ts-node for development and interpret the typescript directly. This is probably the simplest solution and the one that I went with.

Upvotes: 2

Related Questions