-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Find APIs should possibly return undefined #76
Comments
Hey, @camchenry. Thank you for yet another suggestion! Would Lines 136 to 140 in f8da857
|
I have noticed this some day ago and put it in the pr #67. Today i'll rebase the branch |
Yeah, const entity = db.entity.findFirst(...);
if (!entity) {
throw new Error(); // or return 404
}
// entity is now guaranteed to not be null/undefined Thinking about it a little more though, this should probably only apply to the |
Agree on that: let's retain |
I believe with @67 merged Lines 129 to 141 in 5cc1d73
|
Hi, I am having multiple issues, the biggest of which currently is that the
findMany
andfindFirst
APIs do not allow for the possibility of returningundefined
, even though they may do so. This causes TypeScript to not be able to type check this properly and results in run-time type errors.CodeSandbox example:
https://codesandbox.io/s/mswjs-undefined-type-error-omifi?file=/src/App.tsx
I think these APIs should have the type like
T | undefined
(whereT
is the entity) rather than just returningT
unconditionally.The text was updated successfully, but these errors were encountered: