1 | <h1>ts-compiler</h1>
|
2 |
|
3 | <blockquote>
|
4 | <p>TypeScript compilation via the <a href="https://github.com/jedmao/typescript-api">typescript-api</a>.</p>
|
5 | </blockquote>
|
6 |
|
7 | <p>This version is compatable with TypeScript 0.9.5.</p>
|
8 |
|
9 | <p><a href="http://travis-ci.org/jedmao/ts-compiler"><img src="https://secure.travis-ci.org/jedmao/ts-compiler.png?branch=master" alt="Build Status" /></a><br />
|
10 | <a href="https://gemnasium.com/jedmao/ts-compiler"><img src="https://gemnasium.com/jedmao/ts-compiler.png" alt="Dependency Status" /></a><br />
|
11 | <a href="http://badge.fury.io/js/ts-compiler"><img src="https://badge.fury.io/js/ts-compiler.png" alt="NPM version" /></a><br />
|
12 | <a href="https://sourcegraph.com/github.com/jedmao/ts-compiler"><img src="https://sourcegraph.com/api/repos/github.com/jedmao/ts-compiler/counters/views-24h.png" alt="Views" /></a></p>
|
13 |
|
14 | <p><a href="https://nodei.co/npm/ts-compiler/"><img src="https://nodei.co/npm/ts-compiler.png?downloads=true" alt="NPM" /></a></p>
|
15 |
|
16 | <h2>TypeScript Usage</h2>
|
17 |
|
18 | <p>```ts<br />
|
19 | /// <reference path="node_modules/ts-compiler/ts-compiler.d.ts" /><br />
|
20 | import ts = require('ts-compiler');</p>
|
21 |
|
22 | <p>ts.compile(<br />
|
23 | ['foo.ts', 'bar.ts'],<br />
|
24 | { skipWrite: true },<br />
|
25 | (err: Error, results: ts.OutputFile[]) => {</p>
|
26 |
|
27 | <pre><code>var foo = results[0];
|
28 | console.log(foo.text);
|
29 |
|
30 | var bar = results[1];
|
31 | console.log(bar.text);
|
32 | </code></pre>
|
33 |
|
34 | <p>});<br />
|
35 | ```</p>
|
36 |
|
37 | <h2>JavaScript Usage</h2>
|
38 |
|
39 | <p>```js<br />
|
40 | var ts = require('ts-compiler');</p>
|
41 |
|
42 | <p>ts.compile(<br />
|
43 | ['foo.ts', 'bar.ts'],<br />
|
44 | { skipWrite: true },<br />
|
45 | function(err, results) {</p>
|
46 |
|
47 | <pre><code>var foo = results[0];
|
48 | console.log(foo.text);
|
49 |
|
50 | var bar = results[1];
|
51 | console.log(bar.text);
|
52 | </code></pre>
|
53 |
|
54 | <p>});<br />
|
55 | ```</p>
|
56 |
|
57 | <h2>Module API</h2>
|
58 |
|
59 | <h3>ts.compile(globs: string[], options?: ICompilerOptions, callback?: Function)</h3>
|
60 |
|
61 | <ul>
|
62 | <li>This is a shorthand way to call <code>new ts.BatchCompiler.compile(...)</code></li>
|
63 | <li>Callback signature is err: Error, results: <a href="#tsoutputfile">ts.OutputFile</a> Array.</li>
|
64 | <li>The globs array also supports grunt-like glob syntax, as defined in <a href="https://github.com/jedmao/simple-glob">simple-glob</a>.</li>
|
65 | <li>The options follow the <a href="#tsicompileroptions">ICompilerOptions interface</a>.</li>
|
66 | </ul>
|
67 |
|
68 | <h3>ts.OutputFile</h3>
|
69 |
|
70 | <ul>
|
71 | <li>name: string</li>
|
72 | <li>writeByteOrderMark: boolean</li>
|
73 | <li>text: string</li>
|
74 | <li>fileType: (0: JavaScript, 1: SourceMap, 2: Declaration)</li>
|
75 | <li>sourceMapEntries: SourceMapEntry[]</li>
|
76 | </ul>
|
77 |
|
78 | <h3>ts.ICompilerOptions</h3>
|
79 |
|
80 | <p>Though all natively supported TypeScript compiler options will be passed through to the real compiler, it might not always make sense from an API standpoint. Use with common sense.</p>
|
81 |
|
82 | <h4>options.declaration</h4>
|
83 |
|
84 | <ul>
|
85 | <li>Type: <code>Boolean</code></li>
|
86 | <li>Default: <code>false</code></li>
|
87 | </ul>
|
88 |
|
89 | <p>Generates corresponding .d.ts file.</p>
|
90 |
|
91 | <h4>options.mapRoot</h4>
|
92 |
|
93 | <ul>
|
94 | <li>Type: <code>String</code></li>
|
95 | </ul>
|
96 |
|
97 | <p>Specifies the location where debugger should locate map files instead of generated locations.</p>
|
98 |
|
99 | <h4>options.module</h4>
|
100 |
|
101 | <ul>
|
102 | <li>Type: <code>String</code></li>
|
103 | </ul>
|
104 |
|
105 | <p>Specify module code generation: <code>commonjs</code> or <code>amd</code></p>
|
106 |
|
107 | <h4>options.noImplicitAny</h4>
|
108 |
|
109 | <ul>
|
110 | <li>Type: <code>Boolean</code></li>
|
111 | <li>Default: <code>false</code></li>
|
112 | </ul>
|
113 |
|
114 | <p>Warn on expressions and declarations with an implied <code>any</code> type.</p>
|
115 |
|
116 | <h4>options.noResolve</h4>
|
117 |
|
118 | <ul>
|
119 | <li>Type: <code>Boolean</code></li>
|
120 | <li>Default: <code>false</code></li>
|
121 | </ul>
|
122 |
|
123 | <p>Skip resolution and preprocessing.</p>
|
124 |
|
125 | <h4>options.out</h4>
|
126 |
|
127 | <ul>
|
128 | <li>Type: <code>String</code></li>
|
129 | </ul>
|
130 |
|
131 | <p>Concatenate and emit output to single file.</p>
|
132 |
|
133 | <h4>options.outDir</h4>
|
134 |
|
135 | <ul>
|
136 | <li>Type: <code>String</code></li>
|
137 | </ul>
|
138 |
|
139 | <p>Redirect output structure to the directory.</p>
|
140 |
|
141 | <h4>options.removeComments</h4>
|
142 |
|
143 | <ul>
|
144 | <li>Type: <code>Boolean</code></li>
|
145 | <li>Default: <code>false</code></li>
|
146 | </ul>
|
147 |
|
148 | <p>Do not emit comments to output.</p>
|
149 |
|
150 | <h4>options.sourcemap</h4>
|
151 |
|
152 | <ul>
|
153 | <li>Type: <code>Boolean</code></li>
|
154 | <li>Default: <code>false</code></li>
|
155 | </ul>
|
156 |
|
157 | <p>Generates corresponding .map file.</p>
|
158 |
|
159 | <h4>options.sourceRoot</h4>
|
160 |
|
161 | <ul>
|
162 | <li>Type: <code>String</code></li>
|
163 | </ul>
|
164 |
|
165 | <p>Specifies the location where debugger should locate TypeScript files instead of source locations.</p>
|
166 |
|
167 | <h4>options.target</h4>
|
168 |
|
169 | <ul>
|
170 | <li>Type: <code>String</code></li>
|
171 | <li>Default: <code>ES3</code></li>
|
172 | </ul>
|
173 |
|
174 | <p>Specify ECMAScript target version: 'ES3' or 'ES5'</p>
|
175 |
|
176 | <h4>options.optionsFile</h4>
|
177 |
|
178 | <ul>
|
179 | <li>Type: <code>String</code></li>
|
180 | </ul>
|
181 |
|
182 | <p>Insert command line options and files from a file. This is natively supported by the tsc command, but as a different @file key.</p>
|
183 |
|
184 | <h4>skipWrite</h4>
|
185 |
|
186 | <ul>
|
187 | <li>Type: <code>Boolean</code></li>
|
188 | <li>Default: <code>false</code></li>
|
189 | </ul>
|
190 |
|
191 | <p>Skips writing the output files. This flag is unique to ts-compiler.</p>
|
192 |
|
193 | <h2>License</h2>
|
194 |
|
195 | <p>Released under the MIT license.</p>
|
196 |
|
197 | <p><a href="https://bitdeli.com/free" title="Bitdeli Badge"><img src="https://d2weczhvl823v0.cloudfront.net/jedmao/ts-compiler/trend.png" alt="Bitdeli Badge" /></a></p>
|