Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Why use any everywhere? #3

Open
aldamai opened this issue Oct 16, 2024 · 0 comments
Open

Why use any everywhere? #3

aldamai opened this issue Oct 16, 2024 · 0 comments

Comments

@aldamai
Copy link

aldamai commented Oct 16, 2024

Ran into a stupid mistake, I set the user as follow:

      setUser({
        id: userPermissions.username,
        roles: [userPermissions.role],
        permissions: [userPermissions.permissions],
      });

correct way:

      setUser({
        id: userPermissions.username,
        roles: [userPermissions.role],
        permissions: userPermissions.permissions,
      });

The issue was that userPermissions.permissions was already an array of strings, so I unintentionally wrapped it in another array. It took me a while to debug and realize the data type was incorrect, but I didn't get any warnings or errors to help catch this mistake.

Is there a way to use generics or another approach to prevent this type of mistake in the future?

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

No branches or pull requests

1 participant