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
chore: make event store accept IUser #3076
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
src/lib/types/events.ts
Outdated
typeof createdBy === 'string' || typeof createdBy === 'undefined' | ||
? createdBy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This maintains the same behaviour as before, if createdBy
is passed as undefined we propagate that (which should break DB constraints and display an error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
this.createdBy = | ||
typeof createdBy === 'string' | ||
? createdBy | ||
: extractUsernameFromUser(createdBy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reusing an existing function: https://github.com/Unleash/unleash/blob/03c34995466ab8f13f188c588b28c8d74c819c49/src/lib/util/extract-user.ts
After enabling strictNullChecks this PR would be increasing the number of null check errors from 498 to 499. Make sure your branch is up-to-date with main and check the diff in the console output to gather more details |
About the changes
Currently, we need to remember of using the email or else the username of a user when storing into EventStore, because we don't have strictNullChecks, it's error-prone. Fix for a production issue: #3072
I tried enabling strictNullChecks in our tsconfig file, but it reports 509 issues in 143 files.
This means we also need to check for undefined here:
unleash/src/lib/types/events.ts
Lines 144 to 147 in 479d2f1