How to use EmojiOne with Ionic3 and Typescript?

372 Views Asked by At

I just wanna use EmojiOne on an Ionic3 app.

Here is the repository: https://github.com/emojione/emojione

Here is the function I wanna use: unicodeToImage:

https://github.com/emojione/emojione/blob/master/lib/js/emojione.js#L316

But as you can see it is plain Javascript.

I don't wanna change anything inside the code on node_modules after I install it with: npm install emojione (as they recommend), because I want my app be ready for future updates.

Any idea on how I can import this library into my Ionic3 app?

Thanks!

1

There are 1 best solutions below

0
Suraj Rao On BEST ANSWER

To use a javascript library in ts environment (when it is not ES6), you need to use type declaration file.

There seems to be one for emojione package in npm.

Do:

npm i --save-dev @types/emojione

and in your ts file

import * as emojione from emojione;

You can find the declaration file in definitelyTyped project