In a project created with angular2-cli I need to use some 3rd part javascript libraries that should be available in the global javascript scope (for example TWEEN namespace from the tween.js library).
Accordingly to the angular-cli guide to install a js library as global I've installed it with npm and add the library script in the "scripts" array of the angular-cli.json file.
"scripts": [
"../node_modules/tween.js/src/Tween.js"
],
To use the global TWEEN namespace in an angular component I've declared it as a constant variable at the beginning of the file, like the following:
import { Component, OnInit } from '@angular/core';
declare const TWEEN: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'app works!';
constructor() { }
ngOnInit() {
let tween = new TWEEN.Tween({x: 0}).to({x: 1}, 2000);
// ..
}
}
This works, but the problem is that I am not getting any intellisense for any of the 3rd part libraries in this way (I am using WebStorm). Is there anything I can do to get intellisense working? Or are there better ways to import 3rd part javascript libraries in an angular 2 workflow?