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

From Discord: Error when overriding toString method of schema class in browser #4577

Closed
effect-bot opened this issue Mar 10, 2025 · 0 comments · Fixed by #4584
Closed

From Discord: Error when overriding toString method of schema class in browser #4577

effect-bot opened this issue Mar 10, 2025 · 0 comments · Fixed by #4584
Assignees
Labels

Comments

@effect-bot
Copy link

Summary

In the conversation, danielo515 reports an issue encountered when attempting to override the toString method of schema classes in the Effect TypeScript library. The error occurs only in the browser and is described as a TypeError, indicating that toString is a read-only property that cannot be reassigned.

gcanti suggests that the issue might be because the toString property on schema classes is not writable, as seen in the library's source code. They provide a link to the relevant code snippet on GitHub, which shows that toString is indeed set with writable: false.

danielo515 questions why this issue is only present in the browser environment and seeks a way to make the toString property configurable, so it can be overridden conveniently.

gcanti implies that setting writable: true in the property definition might solve the issue.

Key Takeaways:

  • Overriding built-in methods like toString can lead to errors if the property is not writable.
  • This issue might appear differently across environments (Node.js vs. Browser).
  • Making properties writable can provide flexibility but should be done with caution to avoid unintended side effects.
  • Reviewing the library's source code can provide insights into why certain behaviors occur.

Discord thread

https://discord.com/channels/795981131316985866/1348711386527826061

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

Successfully merging a pull request may close this issue.

2 participants