You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is an issue? Please explain with some screenshots.
I tried to apply T | E return type for intermediate functions, such as Service, Repository, and Domain. T means a type of success result, otherwise, E means a type of failure(expected error) result.
In this case, just returning of FailureName to set failure cases makes the ambiguity of returning type for failures.
If we apply a new type to pick FailureName as the list of FailureName, we can specify the returning failure types.
✨ Expected Results
What result do you expect?
For example, define UserService.getUserById(id: string). The function getUserById finds the user by input ID.
If a user is not found, it occurs USER_NOT_FOUND failure, and returns USER_NOT_FOUND as the type FailureName.
However, the use side of function cannot know what failure will be returned, the function can know only that the return type is FailureName. Therefore, defining more specific type definition and detailed failure handling by the definition should be achieved.
The text was updated successfully, but these errors were encountered:
📸 What is this issue?
I tried to apply
T | E
return type for intermediate functions, such asService
,Repository
, andDomain
.T
means a type of success result, otherwise,E
means a type of failure(expected error) result.In this case, just returning of
FailureName
to set failure cases makes the ambiguity of returning type for failures.If we apply a new type to pick
FailureName
as the list ofFailureName
, we can specify the returning failure types.✨ Expected Results
For example, define
UserService.getUserById(id: string)
. The functiongetUserById
finds the user by input ID.If a user is not found, it occurs
USER_NOT_FOUND
failure, and returnsUSER_NOT_FOUND
as the typeFailureName
.However, the use side of function cannot know what failure will be returned, the function can know only that the return type is
FailureName
. Therefore, defining more specific type definition and detailed failure handling by the definition should be achieved.The text was updated successfully, but these errors were encountered: