Permalink
Browse files

TypeScript language support

  • Loading branch information...
1 parent 5139dd6 commit 353323759839a547fe4fa0453739ba8cf37fe071 @remy remy committed Oct 7, 2012
Showing with 73 additions and 1 deletion.
  1. +1 −1 package.json
  2. +1 −0 public/js/editors/panel.js
  3. +43 −0 public/js/processors/processor.js
  4. +27 −0 public/js/vendor/typescript.min.js
  5. +1 −0 views/index.html
View
@@ -7,7 +7,7 @@
"name": "jsbin",
"description": "Collaborative JavaScript Debugging App",
"main": "./lib/app",
- "version": "3.0.11",
+ "version": "3.0.12",
"preferGlobal": "true",
"homepage": "http://jsbin.com",
"bin": "./bin/jsbin",
@@ -5,6 +5,7 @@ var editorModes = {
html: 'htmlmixed',
javascript: 'javascript',
css: 'css',
+ typescript: 'javascript',
markdown: 'markdown',
coffeescript: 'coffeescript',
less: 'css',
@@ -81,6 +81,49 @@ var processors = jsbin.processors = {
return renderedCode;
});
},
+ typescript: function (ready) {
+ return new Processor(jsbin.root + '/js/vendor/typescript.min.js', ready, function (source) {
+ var noop = function () {};
+ var outfile = {
+ source: "",
+ Write: function (s) {
+ this.source += s;
+ },
+ WriteLine: function (s) {
+ this.source += s + "\n";
+ },
+ Close: noop
+ };
+
+ var outerr = {
+ Write: noop,
+ WriteLine: noop,
+ Close: noop
+ };
+
+ var parseErrors = [];
+
+ var compiler = new TypeScript.TypeScriptCompiler(outfile, outerr);
+
+ compiler.setErrorCallback(function (start, len, message) {
+ parseErrors.push({ start: start, len: len, message: message });
+ });
+ compiler.parser.errorRecovery = true;
+
+ compiler.addUnit(source, 'jsbin.ts');
+ compiler.typeCheck();
+ compiler.reTypeCheck();
+ compiler.emit();
+
+ for (var i = 0, len = parseErrors.length; i < len; i++) {
+ console.log('Error Message: ' + parseErrors[i].message);
+ console.log('Error Start: ' + parseErrors[i].start);
+ console.log('Error Length: ' + parseErrors[i].len);
+ }
+
+ return outfile.source;
+ });
+ },
markdown: function (ready) {
return new Processor(jsbin.root + '/js/vendor/markdown.js', function () {
$.getScript(jsbin.root + '/js/vendor/codemirror2/markdown.js', ready);
Oops, something went wrong.
View
@@ -215,6 +215,7 @@
<a href="#coffeescript">CoffeeScript</a>
<a href="#processing">Processing</a>
<a href="#traceur">Traceur</a>
+ <a href="#typescript">TypeScript</a>
<a href="#convert">Convert to JavaScript</a>
</div>
</div>

0 comments on commit 3533237

Please sign in to comment.