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: Issue with erasing B from the context and runtime error #416

Open
effect-bot opened this issue Dec 24, 2023 · 0 comments
Open

Comments

@effect-bot
Copy link

Summary

In the above conversation, there was a discussion about an issue with erasing B from the context and a runtime error. The code provided in the example compiled successfully, even though A was missing one of B's properties. It was pointed out that this behavior is due to the way TypeScript's Exclude works, which respects type assignability.

There was a debate about whether this behavior is a bug or a design choice. Some participants argued that it is a bug because it can lead to unexpected runtime errors. Others argued that it is a design choice based on type assignability rules.

The conversation also touched on different approaches to uniquely identifying services, such as using unique symbols or separate identifiers and shapes. It was suggested that the documentation should highlight the potential pitfalls and provide guidance on how to work around them.

Key takeaways from the conversation:

  1. Erasing one service with another in the context can lead to unexpected runtime errors.
  2. TypeScript's type assignability rules can allow assigning a subtype to a supertype, which may not be desirable in certain cases.
  3. Unique symbols or separate identifiers and shapes can help ensure uniqueness and prevent issues with service assignment.
  4. The documentation should clearly explain the potential pitfalls and provide guidance on how to use the API correctly.

Discord thread

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

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

1 participant