Skip to content

Commit

Permalink
[No Ticket] Better typing
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuwalow committed Jan 22, 2024
1 parent be635d3 commit 9ea78fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12
const uuidRegex = new RegExp(`^${UUID}$`, 'i')
const hasTrim = !!String.prototype.trim

export function onNonNull<A, B>(value: A, fn: (value: NonNullable<A>) => B): null | undefined | B {
return value != null ? fn(value) : (value as null | undefined)
export function onNonNull<A, B>(value: A, fn: (value: NonNullable<A>) => B): Exclude<A, NonNullable<A>> | B {
return value != null ? fn(value) : (value as Exclude<A, NonNullable<A>>)
}

export function safeToString(value: unknown): string {
Expand Down

0 comments on commit 9ea78fc

Please sign in to comment.