How To Use Jquery In TypeScript

If you have Typescript installed you can skip to Jquery section directly.

Install TypeScript

Installing Typescript with snowpack is very easy. Before that make sure you have NPM installed.

In your project folder, execute following command...

npx create-snowpack-app . --template @snowpack/app-template-blank-typescript --force

To test if typescript is installed, run following command...

npm start

You should see your browser window with default html page opened.

Install Jquery in TypeScript

npm i jquery
npm i --save-dev @types/jquery

Now let us test if Jquery is working.

In your index.js, type following code, import jquery like this...

import $ from "jquery"

After you save, If you didn't see any error. It means jquery is working fine.