Permalink
Browse files

Narrow `Option.mapN` return type to exclude (#70)

Fixes #69
  • Loading branch information...
OliverJAsh authored and alexandru committed Oct 25, 2017
1 parent 6f551d8 commit 05e87d19d6148e3ba608de1c9cb5d73018ec0593
View
@@ -3,3 +3,5 @@ to project Funfix and that own the copyright of their contributions:
Alexandru Nedelcu
https://github.com/alexandru
Oliver Joseph Ash
https://github.com/OliverJAsh
@@ -89,7 +89,7 @@ declare export class Option<+A> {
hashCode(): number;
isEmpty(): boolean;
map<B>(f: (a: A) => B): Option<B>;
mapN<B>(f: (a: A) => B): Option<B>;
mapN<B>(f: (a: A) => ?B): Option<B>;
nonEmpty(): boolean;
// Implements HK<F, A>
@@ -649,7 +649,7 @@ export class Option<A> implements std.IEquals<Option<A>> {
* .mapN(_ => _.length)
* ```
*/
mapN<B>(f: (a: A) => B): Option<B> {
mapN<B>(f: (a: A) => B | null | undefined): Option<B> {
return this._isEmpty ? None : Option.of(f(this._ref))
}
@@ -81,7 +81,7 @@ const r15: Option<string> =
Option.of(1).map((n: number) => String(n))
const r16: Option<string> =
Option.of(1).mapN((n: number) => String(n))
Option.of(1).mapN((n: number): string | null => null)
const r17: boolean =
Option.of(1).nonEmpty()

0 comments on commit 05e87d1

Please sign in to comment.