Most likely, you need to download and include the TypeScript declaration file for jQuery - jquery.d.ts - in your project.
Option 1. Install the @types package (recommended for TS 2. 0+)
In the same folder as the package.json file, run the following command:
npm install --save-dev @types/jquery
Then the compiler will automatically resolve the definitions for jquery.
Option 2. Manual download (not recommended)
Download it here .
Option 3. Using typing (up to TS 2.0)
If you use typing , you can enable it as follows:
// 1. Install typings npm install typings -g // 2. Download jquery.d.ts (run this command in the root dir of your project) typings install dt~jquery
After setting up the definition file, import the alias ( $ ) into the desired TypeScript file to use as usual.
import $ from "jquery"; // or import $ = require("jquery");
You may need to compile --allowSyntheticDefaultImports - add "allowSyntheticDefaultImports": true in tsconfig.json.
Also install the package?
If you do not have jquery installed, you probably want to install it as a dependency through npm (but this is not always the case):
npm install --save jquery
David Sherret Aug 17 '15 at 14:02 2015-08-17 14:02
source share