Is it possible to use TypeScript and jQuery (or any other non-Node JavaScript library) without AMD?
Currently my code compiles fine, but the compiled code cannot see the jQuery's $ function.
Given this TypeScript code:
/// <reference path="typings/tsd.d.ts" />
import $ = require('jquery');
export class Widget {
foo() {
$(selector).bar()
}
}
I'd like the following JavaScript:
var Widget = (function ($) {
function Widget() { }
Widget.prototype.foo = function () { ... };
return Widget;
})(jQuery);
Currently my code does not have jQuery passed to the anonymous function.
UPDATE 1
Per @basarat
Do it by hand. If its valid JavaScript then its valid TypeScript
You're suggesting (and I was thinking) that I do this:
var Widget = (function($) {
class Widget {
foo() {
$('body').append('foo');
}
}
return Widget;
})(jQuery);
?
That's not valid TypeScript and without that, I'm left with prototypes.
UPDATE 2
Per @basarat the above is supported with TypeScript 1.6.