typescript-register
typescript-register copied to clipboard
Extension to require TypeScript files from Node
TypeScript Register
![Coverage](https://img.shields.io/coveralls/pspeter3/typescript-register/master.svg?style=flat-square)
Deprecated in favor of ts-node
Extension to require TypeScript files from Node. This project is an alternative to typescript-require. The main differences are:
- Dependencies are run in the same context as the parent
- Uses the TypeScript API as opposed to forking
tsc
- Caches dependencies in
/tmp/typescript-register/:your/:path/:here
Examples
foo.ts
export var foo = 3;
bar.js
require('typescript-register');
var foo = require('./foo');
console.log(foo.foo);
Installation
Install with npm:
npm install typescript-register
Configuration
There are three configuration options which are read from environment variables. The configuration options are read each time a module is required so you can programatically set them with:
process.env[':name'] = ':value';
The values are:
-
TYPESCRIPT_REGISTER_EMIT_ERROR
: Whether or not emit fatal TypeScript errors -
TYPESCRIPT_REGISTER_USE_CACHE
: Whether or not to use previously emitted files -
TYPESCRIPT_REGISTER_COMPILER_OPTIONS
: The JSON stringified TypeScript compiler options
Contributing
Feel free to fork and submit pull requests for the code! Please follow the existing code as an example of style and make sure that all your code passes tests.