UsersService: Merge if-statements and add null to return type in toUserDto

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-09-26 16:00:17 +02:00
parent a028dac448
commit 8fada8809c
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -26,13 +26,9 @@ export class UsersService {
} }
} }
toUserDto(user: User): UserInfoDto { toUserDto(user: User | null | undefined): UserInfoDto | null {
if (user === undefined) { if (!user) {
this.logger.warn('toUserDto recieved undefined argument!'); this.logger.warn(`toUserDto recieved ${user} argument!`);
return null;
}
if (user === null) {
this.logger.warn('toUserDto recieved null argument!');
return null; return null;
} }
return { return {