@ts-tools/node
v6.0.0
Published
TypeScript support for Node.js.
Downloads
10,332
Readme
@ts-tools/node
TypeScript support for Node.js.
This package installs a require extension, adding support for running .ts
and .tsx
files directly from source.
Features:
- Fast! Uses
ts.transpileModule
. Leaves type checking to other flows. - Uses persistent disk caching (
./node_modules/.cache/ts-<module>-<target>
). Second run will not re-transpile a file if not changed. - Built-in support for source-maps, powered by source-map-support.
- Node 8+ friendly default compiler options.
Getting started
Install the library as a dev dependency in an existing TypeScript project:
npm i @ts-tools/node --save-dev
Usage with Node.js:
node -r @ts-tools/node/r ./my-script.ts
Usage with Mocha:
mocha -r @ts-tools/node/r "./test/**/*.test.ts?(x)" --watch-extensions ts,tsx
OR, create a .mocharc.js
file with:
module.exports = {
require: ['@ts-tools/node/r'],
extension: ['js', 'json', 'ts', 'tsx'],
};
Usage with Visual Studio Code:
// in .vscode/launch.json, under "configurations"
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeArgs": ["-r", "@ts-tools/node/r"],
"args": ["${workspaceFolder}/src/my-script.ts"],
}
Similar projects
ts-node - a much more complete solution. It includes a ts-node
cli/repl, and require hook registration.
License
MIT