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

[BUG] Network type interpreted as ANY #964

Open
just2102 opened this issue Feb 19, 2024 · 0 comments
Open

[BUG] Network type interpreted as ANY #964

just2102 opened this issue Feb 19, 2024 · 0 comments

Comments

@just2102
Copy link

just2102 commented Feb 19, 2024

Describe the bug
EmptyNetwork is defined using ValidNetwork<string, never>, which suggests that ValidNetwork was intended to be a generic type. However, ValidNetwork is defined as a concrete type with specific properties and does not accept generic parameters. This is why TypeScript interprets EmptyNetwork as any.

To Reproduce
Steps to reproduce the behavior:

  1. Go to: src/types/network.d.ts
  2. Check type of EmptyNetwork

Expected behavior
If the goal is to create a type EmptyNetwork that represents a "network" with potentially missing or empty fields based on ValidNetwork, generics should not be used in this case.
Instead, you can use utility types like Partial for making all properties optional or use other TypeScript features to modify the existing ValidNetwork type.

Screenshots
image

Additional context
In the current implementation the type of Network is quite useless, because it implies being "any" because of this incosistency with EmptyNetwork.
Possible solution would look something like this:

type EmptyNetwork = Partial<ValidNetwork>;
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