I'm trying to intregate JQUERY into Typescript but I hit a brick wall and I don't know how to get over it. Bear in mind that I'm a newbie when it comes to Typescript (been messing with it for a couple of months only), so there is a chance that this problem is very easy to solve but I can't figure it out.
So, I have this very simple program in TS:
/// <reference path="node_modules/@types/jquery/index.d.ts" />
function PrintName()
{
let name:any = $('#txtName').val();
console.log(name);
}
But when I run it in the web I get the error: Uncaught ReferenceError: $ is not defined at PrintName
But, when I include this line in the HTML:
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
It works just fine. So, how can I add Jquery to the Typescript ? I tried with this command:
npm install --save-dev @types/jquery
And then adding the reference to index.d.ts, but I get the same error. I'm using Visual Studio Code 1.27, tsc 3.0.1 and npm 3.5
Thanks!