Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ts-node programmatic usage with require('ts-node/register')

ts-node suggests to use require('ts-node/register'). And this can be seen in angular2-webpack-starter Protractor configuration.

What is require('ts-node/register') supposed to do? Does it patch require to transpile TS files, so a part of Node.js application could be written in TypeScript?

like image 964
Estus Flask Avatar asked Aug 23 '16 18:08

Estus Flask


1 Answers

It does what you think it does. require('ts-node/register') is actually the same as:

require('./').register({
    lazy: true
})

See examples here: https://github.com/TypeStrong/ts-node/tree/master/register

The .register function registers the Typescript compiler for files with .ts and .tsx extension for compilation on the fly.

like image 119
vincent Avatar answered Oct 01 '22 03:10

vincent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!