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 create property 'displayName' on number 'Infinity' #79

Closed
power-f-GOD opened this issue Nov 13, 2023 · 7 comments · Fixed by #80
Closed

TypeError: Cannot create property 'displayName' on number 'Infinity' #79

power-f-GOD opened this issue Nov 13, 2023 · 7 comments · Fixed by #80

Comments

@power-f-GOD
Copy link

Infinity is a number (and/or reserved word) in JavaScript, hence the Infinity icon's name conflicts with the same.

Screenshot 2023-11-13 at 9 21 14 PM

This makes my NextJS (14) app build break.

Screenshot 2023-11-13 at 9 12 27 PM
@rektdeckard
Copy link
Member

Just use import aliasing to rename it to whatever you want. We have addressed this one before, andInfinity is not the only JS or web platform global that gets reused.

import { Infinity as InfinityIcon } from "@phosphor-icons/react”;

@power-f-GOD
Copy link
Author

The error occurs during compilation (or should I say in the compiled/built code) independent of whether I'm using the icon or not.

Currently, I am not using the icon, I don't have it imported anywhere.

...Infinity is not the only JS or web platform global that gets reused.

That's not good practice, IMO. And even if the global must be "reused" (overridden), then they should, at least, have the same base (data) type.

Now, the compiler sees Infinity and reckons it is a number, but it is a RFC in this context.💔

@markmssd
Copy link

We're running into the same issue, @power-f-GOD did you find a workaround? 🙏🏼

@rektdeckard
Copy link
Member

We've decided to rename the icon Lemniscate, which is apparently another name for the symbol. It will continue to be available under the Infinity alias, bust since we aren't assigning anything to the Infinity global, this should serve you well and not break compatibility for existing users. Expect this patch in a day or two.

@rektdeckard
Copy link
Member

@power-f-GOD to clarify what I meant, we will be careful not to use global names internally, but it should not matter if we provided aliased named exports that occasionally conflict with globals.

@markmssd
Copy link

Thanks @rektdeckard ! Let's hope it helps 🤞🏼 As @power-f-GOD mentioned, even if the icon is not used, the error occurs during compilation (in our case, during Jest test runs). Let's see! 🥁

@rektdeckard
Copy link
Member

Try upgrading to@phosphor-icons/react@2.0.15, should have fixed the issue

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

Successfully merging a pull request may close this issue.

3 participants