├── README.md ├── index.html ├── typescript.interpret.js └── typescript.interpret.min.js /README.md: -------------------------------------------------------------------------------- 1 | TypeScript Interpret 2 | ================== 3 | 4 | [TypeScript](http://www.typescriptlang.org) is a brand new language which compiles on JavaScript. However, this operation has to be performed manually, using the command-line compiler `tsc` or other tools. But now it can be interpreted straight in your web browser, thanks to TypeScript Interpret! 5 | 6 | TypeScript Interpret automatically interprets your TypeScript code typed into a console, using the [jQuery Terminal](https://github.com/jcubic/jquery.terminal) by Jakub Jankiewicz. 7 | 8 | 9 | Demo 10 | ---- 11 | 12 | [Here is a TypeScript terminal emulator](http://niutech.github.com/typescript-interpret/) 13 | 14 | 15 | Download 16 | -------- 17 | 18 | [TypeScript 0.8](https://raw.github.com/niutech/typescript-compile/gh-pages/js/typescript.min.js) (minified JS) 19 | 20 | [TypeScript Interpret 0.2](https://raw.github.com/niutech/typescript-interpret/gh-pages/typescript.interpret.min.js) (minified JS) 21 | 22 | [jQuery Terminal 0.4.22](https://raw.github.com/jcubic/jquery.terminal/master/js/jquery.terminal-0.4.22.min.js) (minified JS) 23 | 24 | 25 | Authors & License 26 | ---------------- 27 | 28 | TypeScript is developed by Microsoft Corp. under Apache 2.0 License. 29 | 30 | TypeScript Interpret is developed by Jerzy Głowacki under Apache 2.0 License. 31 | 32 | jQuery Terminal is developed by Jakub Jankiewicz under GNU GPL 3 License. -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TypeScript Interpret - Terminal Emulator 6 | 7 | 20 | 23 | 24 | 25 | Fork me on GitHub 26 |
27 | 28 | 29 | 30 | 31 | 32 | 84 | 85 | -------------------------------------------------------------------------------- /typescript.interpret.js: -------------------------------------------------------------------------------- 1 | var TypeScriptInterpret = { 2 | 3 | outfile: { 4 | source: '', 5 | Write: function(s) { 6 | this.source += s; 7 | }, 8 | WriteLine: function(s) { 9 | this.source += s + '\n'; 10 | }, 11 | Clear: function() { 12 | this.source = ''; 13 | }, 14 | Close: function() {} 15 | }, 16 | 17 | interpret: function(cmd) { 18 | this.outfile.Clear(); 19 | var compiler = new TypeScript.TypeScriptCompiler(this.outfile); 20 | compiler.parser.errorRecovery = true; 21 | compiler.setErrorCallback(function(start, len, message, block) { 22 | throw 'TypeScriptError: ' + message + ', char: ' + start + ', length: ' + len; 23 | }); 24 | compiler.addUnit(cmd, ''); 25 | //compiler.typeCheck(); //Disabled due to exclusion of lib.d.ts 26 | compiler.emit(false, function(fileName) { 27 | return this.outfile; 28 | }); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /typescript.interpret.min.js: -------------------------------------------------------------------------------- 1 | var TypeScriptInterpret={outfile:{source:"",Write:function(a){this.source+=a},WriteLine:function(a){this.source+=a+"\n"},Clear:function(){this.source=""},Close:function(){}},interpret:function(a){this.outfile.Clear();var b=new TypeScript.TypeScriptCompiler(this.outfile);b.parser.errorRecovery=!0;b.setErrorCallback(function(a,b,c){throw"TypeScriptError: "+c+", char: "+a+", length: "+b;});b.addUnit(a,"");b.emit(!1,function(){return this.outfile})}}; --------------------------------------------------------------------------------