Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'mask') #153

Closed
krajcikondra opened this issue Feb 22, 2022 · 3 comments
Closed

Comments

@krajcikondra
Copy link

krajcikondra commented Feb 22, 2022

Hi,

am facing to following issue:

    import EmojiConvertor from 'emoji-js';

    const emojiConvert = (sanitizedHTML: string, emojiSet?: string): string => {
        const emojiConvertor = new EmojiConvertor();
        const msgHtml = sanitizedHTML.replace(/\n$/,'');
        emojiConvertor.img_sets.google.sheet = '/emoji-data/sheet_' + emojiSet + '_64.png';
        emojiConvertor.use_sheet = false;

        emojiConvertor.replace_mode = 'img';
        emojiConvertor.img_set = emojiSet;
        emojiConvertor.include_title = true;

        return emojiConvertor.replace_colons(msgHtml);
    }

And when I call function

emojiConvert('hello :alien:');

I get following error:
TypeError: Cannot read properties of undefined (reading 'mask')

Screen here: https://ctrlv.cz/gpcx

I am using emoji-js version 3.6.0

Some tips?

@iamcal
Copy link
Owner

iamcal commented Mar 4, 2022

I can't get as far as you to check, because I don't know what toolchain and VM you're using (this is typescript, so how are you compiling it and where are you running it?).

My guess would be that you're passing an invalid value to .img_set and so it's failing to find all the information it needs to initialize. What happens if you call emojiConvert('hello :alien:', 'apple'); instead?

@krajcikondra
Copy link
Author

I am sorry, my mistake. I passed emojiSet undefined.
@iamcal thanks

iamcal added a commit that referenced this issue Mar 10, 2022
- added test to check that works
- avoids issue #153
iamcal added a commit that referenced this issue Mar 10, 2022
- added test to check that works
- avoids issue #153
@iamcal
Copy link
Owner

iamcal commented Mar 10, 2022

The errors should be less confusing!

I've just landed PR #156 on master which in future will throw an exception in this situation, explaining what is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants