I need to replace some emojis with images so I am using emoji-regex to find them and get the true length of the emoji so that it can be substituted, they recommend using ...
[...emoji].length
... that under certain tsconfig.json options, will be transpiled to ...
__spreadArray([], emoji, true).length
I have tried other variations, including Array.from() and emoji.length, and only the variation above yields accurate lengths. Fortunately, swallowing the error in a try-catch seems to work so it seems the error is not critical for spreadArray to function for some reason and I do not know why.
Expected behavior
No error occurs when
spreadArray
is used on a string containing an emoji/Unicode character.Current behavior
When
spreadArray
is used on a string containing an emoji/Unicode character, the following error occurs:I believe the problem is related to https://github.com/microsoft/tslib/blob/2.3.1/tslib.js#L208 because if you run ...
... the same error occurs.
Steps to reproduce
https://codesandbox.io/s/beautiful-cohen-86fygb?file=/src/index.js:220-251
Context
I need to replace some emojis with images so I am using emoji-regex to find them and get the true length of the emoji so that it can be substituted, they recommend using ...
... that under certain
tsconfig.json
options, will be transpiled to ...I have tried other variations, including
Array.from()
andemoji.length
, and only the variation above yields accurate lengths. Fortunately, swallowing the error in atry-catch
seems to work so it seems the error is not critical forspreadArray
to function for some reason and I do not know why.