I've encountered an issue while trying to use jQuery in my Angular-TypeScript project. After installing jquery using "npm install @type/jquery", I am receiving the following error when trying to serve:
Error TS2592: Cannot find name '$'. Is it necessary to install type definitions for jQuery? You can try running npm i @types/jquery
and then add jquery
to the types field in your tsconfig.
How can I successfully add jquery to the types field?
Here's a snippet of my code:
let settings = {
"async": true,
"crossDomain": true,
"url": "https://api.com/getSomething",
"method": "POST",
"headers": {
"x-rapidapi-host": "xxx",
"x-rapidapi-key": "xxx",
"content-type": "xxx"
},
"data": {}
}
$.ajax(settings).done(function (response) {
console.log(response);
});