Skip to content

Commit

Permalink
fix(maybe): fix map function types
Browse files Browse the repository at this point in the history
  • Loading branch information
futantan committed Oct 31, 2019
1 parent 4464782 commit 1a4bad7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Maybe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export class Maybe<T> implements Omit<Monad<T>, 'of'> {
return new Maybe<never>(null)
}

static of<T>(value: T | null): Maybe<T> {
static of<T>(value: T | null | undefined): Maybe<T> {
return value == null ? Maybe.Nothing : Maybe.Just<T>(value)
}

private constructor(private v: T | null) {}

map<U>(f: (x: NonNullable<T>) => U): Maybe<U> {
map<U>(f: (x: NonNullable<T>) => U | null | undefined): Maybe<U> {
return this.v == null ? Maybe.Nothing : Maybe.of<U>(f(this.v!))
}

Expand Down

0 comments on commit 1a4bad7

Please sign in to comment.