I'm new to Typscript 2. What i'm trying to do is to use jQuery within typescript. In this question i read that you need two things:
npm install --save-dev @types/jquery
This installs package '@types/jquery 2.0.39'.
"devDependencies": {
"@types/jquery": "^2.0.39",
"typescript": "^2.0.2",
"typings": "^1.0.4"
}
Then, in the Typescript file i put this:
import $ from "jquery";
but i got typescript error 'Cannot find module 'jquery'. What am I doing wrong?
Same error with
import $ = require("jquery");
Full typescript file:
import { Component } from '@angular/core';
import $ from "jquery";
@Component({
selector: 'my-app',
template: `<div id="test"></div>`,
})
export class AppComponent {
constructor() {
$('#test').html('This is a test');
}
}