Having some difficulty integrating jquery, jquery-ui, and typescript in my project. I used npm to install both jquery and jquery-ui with the following commands:
npm install --save jquery
npm install --save jquery-ui
On my typescript file, I included them like this:
import * as $ from 'jquery';
import 'jquery-ui';
While attempting to create a dialog using jQuery-UI:
$("#my-id").dialog({ modal: true, etc, etc });
VS Code flagged "dialog" with the error message:
Property 'dialog' does not exist on type 'JQuery<HTMLElement>'
I searched for types for jquery-ui on DefinitelyTyped and found them at https://www.npmjs.com/package/@types/jqueryui. After installing it with npm, I added the import statement to my code:
import 'jqueryui'
It's interesting that the types are in 'jqueryui' while jquery-ui itself is 'jquery-ui' with a hyphen.
After resolving the previous error, when trying to bundle using gulp:
gulp bundle --ship
An error occured:
Module not found: Error: Can't resolve 'jqueryui'
Why do I need @types/jqueryui separately instead of including them automatically for typescript?
How can I successfully build without errors when including jqueryui in the project or build without it affecting the outcome?
Any insights would be greatly appreciated!