Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop "property does not exist on type JQuery" syntax errors when using Typescript?

I am only using one line of jQuery in my application:

$("div.printArea").printArea(); 

But this is giving me a Typescript error:

The property 'printArea' does not exist on type JQuery?

Can someone tell me how I can stop this error appearing?

like image 840
Alan2 Avatar asked Jul 27 '14 18:07

Alan2


1 Answers

You could cast it to <any> or extend the jquery typing to add your own method.

 (<any>$("div.printArea")).printArea(); 

//Or add your own custom methods (Assuming this is added by yourself as a part of custom plugin)

interface JQuery {     printArea():void; } 
like image 131
PSL Avatar answered Sep 30 '22 18:09

PSL