12
12
``` sh
13
13
npm install -g ts-node
14
14
15
- # Make sure you install your TypeScript-compatible compiler .
15
+ # Install a TypeScript compiler (requires `typescript` by default) .
16
16
npm install -g typescript
17
17
```
18
18
19
19
## Features
20
20
21
- * Execute TypeScript with node
21
+ ![ TypeScript REPL] ( https://github.com/blakeembrey/ts-node/raw/master/screenshot.png )
22
+
23
+ * Execute TypeScript files with node
22
24
* Interactive REPL
23
- * Execute (and print) TypeScript inline
25
+ * Execute (and print) TypeScript through the CLI
24
26
* Supports source maps
25
27
* Supports ` tsconfig.json `
26
28
@@ -30,40 +32,31 @@ npm install -g typescript
30
32
# Execute a script as you world normally with `node`.
31
33
ts-node script.ts
32
34
33
- # Start a TypeScript REPL
35
+ # Start the TypeScript REPL.
34
36
ts-node
35
37
36
- # Execute code snippets with TypeScript
38
+ # Execute code snippets with TypeScript.
37
39
ts-node -e ' console.log("Hello, world!")'
38
40
39
- # Execute and print code snippets with TypeScript
41
+ # Execute and print code snippets with TypeScript.
40
42
ts-node -p ' "Hello, world!"'
41
43
```
42
44
43
- ** With Mocha**
45
+ ** Mocha: **
44
46
45
47
```
46
48
mocha test.ts --require ts-node/register src/**/*.spec.ts
47
49
```
48
50
49
- ** With Tape:**
51
+ ** Tape:**
50
52
51
53
```
52
54
ts-node tape src/**/*.spec.ts
53
55
```
54
56
55
- ### Using TypeScript With Node Programmatically
56
-
57
- ``` js
58
- require (' ts-node' ).register ({ /* options */ })
59
-
60
- // Or using the shortcut file.
61
- require (' ts-node/register' )
62
- ```
63
-
64
57
### Loading ` tsconfig.json `
65
58
66
- ** Typescript Node** automatically loads ` tsconfig.json ` options and files from the current directory using [ tsconfig] ( https://github.com/TypeStrong/tsconfig ) .
59
+ ** Typescript Node** automatically loads ` tsconfig.json ` options and referenced files from the current directory using [ tsconfig] ( https://github.com/TypeStrong/tsconfig ) .
67
60
68
61
### Configuration Options
69
62
@@ -78,6 +71,15 @@ ts-node --compiler ntypescript --project src --ignoreWarnings 2304 hello-world.t
78
71
* ** ignoreWarnings** Set an array of TypeScript diagnostic codes to ignore.
79
72
* ** disableWarnings** Ignore all TypeScript errors.
80
73
74
+ ### Programmatic Usage
75
+
76
+ ``` js
77
+ require (' ts-node' ).register ({ /* options */ })
78
+
79
+ // Or using the shortcut file.
80
+ require (' ts-node/register' )
81
+ ```
82
+
81
83
## License
82
84
83
85
MIT
0 commit comments