estus estus - 3 months ago 47
TypeScript Question

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

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?

Answer

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

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

See here https://github.com/TypeStrong/ts-node/blob/master/register.js

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

Comments