angulartypescript-typings

How can we use Semantic-UI typings file in angular


Many articles explains how to install typings for thirdy party libraries in Angular2/4, 1. npm install --save-dev jquery, 2. typing install dt~jquery 3. import * as $ from 'jquery'; in the .ts file

So I need someone to explain how we can install Semantic-UI in an Angular2/4 project using typing file: typing install dt~semantic--save in order to use a code like $('.ui.accordion').accordion();. When I try to do this it throw an error in the console,

TypeError: __WEBPACK_IMPORTED_MODULE_5_jquery__(...).accordion is not a function at ...

and the accordion is not working.

Thanks in advance.


Solution

  • Oh I managed to make this work by, after installing the jquery typings file I installed the simantic-ui by typing install dt~semantic --save, and on top of the file: src/typings.d.ts I added this line: /// <reference path="../typings/index.d.ts"/> and that's all.

    BTW: no need of "declare var $: any;" or "import * as $ from 'jquery';" in the .ts files.