The aim of this project is to provide interfaces to the TypeScript compiler in multiple languages.
You can easily compile TypeScript code on-the-fly with this package.
This interface is itself completely written in TypeScript. Therefore you can also reference the *.ts
source file in your existing TypeScript project.
Just include this line on top of your file:
///<reference path="../src/main.ts" />
Include this single file:
<script type="text/javascript" src="js/build/TSCompiler.min.js"></script>
You then can call these functions:
TSCompiler.compileStr()
andTSCompiler.runStr()
TSCompiler.runScriptBlock()
andTSCompiler.runAllScriptBlocks()
TSCompiler.compileExtern()
See the provided samples: http://comfreek.github.com/TSCompiler/demo/
This module accesses the TypeScript compiler on the command line (tsc
).
So you have to install TypeScript before using this interface. But that should be very easy if you already have NodeJS (Don't have it yet? Get it!) installed:
npm install -g typescript
TSCompiler.class.php
defines a static class with two functions (besides two static variables):
TSCompiler::compile()
TSCompiler::compileToStr()
Because the code uses the command line interface, we have to declare an input and output filename. So a temporary file is always created.
You cannot compile a raw string at the current moment but that should not be too difficult to implement.
Developed by @ComFreek!
Checkout my other projects here: http://github.com/ComFreek
The original idea of a JavaScript interface came from here: https://github.com/niutech/typescript-compile.
I have completely rewritten all the code and its the internal structure from scratch.
This is project is licensed under the same license agreement as TypeScript from Microsoft:
Apache License 2.0: http://www.apache.org/licenses/LICENSE-2.0