Despite installing jquery
and @types/jquery
, I am facing issues with getting JQuery to work in my typescript file.
When using:
import * as $ from 'jquery';
$("#test").addClass("className");
I encounter an error on $("#test")
:
TS2349: Cannot invoke an expression whose type lacks a call signature.
Following the suggested change by WebStorm to import like this:
import $ from 'jquery';
No errors appear at the importing stage, but during compilation of the file I face the error:
error TS1192: Module '"C:/Users/Home/Desktop/react/hello-world/node_modules/@types/jquery/index"' has no default export.
Despite going through multiple StackOverflow posts, I have not found any solutions. Any suggestions?