1

I'm building an Ionic app in Angular/Typescript.

I'm using a library called emojiRegex and I'm a little uncertain how to use it.

I'm importing it like this:

import { emojiRegex } from 'emoji-regex';

and then according to the docs you have to require it?

So I'm doing:

let emojiRegex = require('emoji-regex');
if(emojiRegex().test(this.emoji)) {

which works, but I get a typescript error I'd like to remove..

I read you need to add to your `tsconfig.json:

"types": [
  "node"
],

and then run npm install @types/node --save-dev which I did, but it didn't work for me. I just get another error that states:

[10:39:24] typescript error Cannot find type definition file for 'node'.

So any ideas how I can do this? I feel like I'm missing something pretty simple.. Thanks!

Simon
  • 2,498
  • 3
  • 34
  • 77

1 Answers1

5

You should be able to import it as a const like so:

import * as emojiRegex from 'emoji-regex';
Teddy Sterne
  • 13,774
  • 2
  • 46
  • 51