[英]ts-node programmatic usage with require('ts-node/register')
ts-node
suggests to use require('ts-node/register')
. ts-node
建议使用require('ts-node/register')
。 And this can be seen in angular2-webpack-starter
Protractor configuration . 这可以在
angular2-webpack-starter
Protractor配置中看到。
What is require('ts-node/register')
supposed to do? 什么是
require('ts-node/register')
应该做什么? Does it patch require
to transpile TS files, so a part of Node.js application could be written in TypeScript? 它是否
require
转换TS文件,因此Node.js应用程序的一部分可以用TypeScript编写?
It does what you think it does. 它做你认为它做的。
require('ts-node/register')
is actually the same as: require('ts-node/register')
实际上与:
require('./').register({
lazy: true
})
See examples here: https://github.com/TypeStrong/ts-node/tree/master/register 请参阅此处的示例: 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. .register
函数为Typescript编译器注册扩展名为.ts
和.tsx
文件,以便即时编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.