Is it possible to use JavaScript libraries in TypeScript?
For example I want to use Raphael in TypeScript and added the JS files in my /scripts folder
and added them to _references.js
.
But when I want to declare in my TS file:
var r = Raphael(10,50,640,480);
Intellisense always says:
Raphael does not exist in the current scope.
and the TS file does not compile.
This line is an ambient declaration:
declare var Raphael: any;
While it works, you get no real typing.
The project DefinitelyTyped already has definitions for Raphael.
Download the raphael.d.ts file.
And use it like this:
/// <reference path="../Definitions/raphael.d.ts" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With