Z
Z
zeuss562017-05-20 08:33:00
Node.js
zeuss56, 2017-05-20 08:33:00

How to add direct TypeScript support to Node.JS?

How to get Node.JS to process TypeScript directly without transpiling like it already does with ES6?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Kitmanov, 2017-05-20
@zeuss56

https://www.npmjs.com/package/ts-node
Also read the discussion here: https://github.com/Microsoft/TypeScript/issues/1823

M
Michael, 2017-05-21
@mak_ufo

This is much easier to do than you might think. You execute in the console, for example, the following:
And write something like this code in app.ts:

import * as express from 'express';

const app: express.Aplication = new Express();
app.get('/hello', helloMessage);

function helloMessage(req: express.Request, res: express.Response) {
   console.log("Hello!");
}

app.listen(8000)

Well, then just compile through tsc.
See if there is @types/moduleName for the desired module here . If this is not available, then write manually (I did not do this myself, but others say that it is quick and easy).
For reference, you can see this article , but there is a very ancient way of working with typescript described. You don't have to do it

N
Negwereth, 2017-05-20
@Negwereth

No way. TypeScript is not an official specification.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question