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

Stronger Type Safety for Auth0Id #185

Open
brentmclark opened this issue Feb 12, 2021 · 0 comments
Open

Stronger Type Safety for Auth0Id #185

brentmclark opened this issue Feb 12, 2021 · 0 comments

Comments

@brentmclark
Copy link
Collaborator

While creating PR #184 a concern arose wherein the type applied to the auth0Id value in a few places was a string which also happens to accept null and undefined as valid values.

The suggestion at the time was to manually coalesce falsey values to '' using something like this:

auth0Id || ''

Which this will certainly work, I don't believe it's not an ideal habit for us to establish. More specifically, I don't think it's a good use of time to manually enforce a level of type safety that the type checker itself is allowing.

What I propose instead is one or both of the following options:

  1. Enable strict null checks so that none of the types in the system allow null/undefined unless told to do so explicitly. More can be read on this [here](Nullable Types: https://www.typescriptlang.org/docs/handbook/advanced-types.html#nullable-types).
  2. Make a custom type just for the auth0Id that adds type-safe validation as well. Here's an article covering one potential approach.

I'm not expecting any immediate progress on this topic. I think it's wise for us to consider whether or not we want to solve this problem at all, and, if so, how soon we want to solve this problem.

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