Skip to content

Commit

Permalink
fix: fixes mapOrElse typing
Browse files Browse the repository at this point in the history
  • Loading branch information
OctoD committed Dec 18, 2019
1 parent eb4aaca commit bfed50b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiinvo",
"version": "1.5.0",
"version": "1.5.1",
"author": "Paolo Roth <octod>",
"main": "dist/index.js",
"license": "MIT",
Expand Down
10 changes: 5 additions & 5 deletions src/Option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ export class OptionLike<T> {
*
* @template K
* @param {() => K} defFn
* @param {(arg: T) => K} f
* @param {(arg: NonNullable<T>) => K} f
* @returns {K}
* @memberof OptionLike
*/
public mapOrElse<K>(defFn: () => K, f: (arg: T) => K): K {
public mapOrElse<K>(defFn: () => K, f: (arg: NonNullable<T>) => K): K {
ensureFunction("mapOrElse argument must be a function", f);

return this.isSome() ? f(this.value) : defFn();
return this.isSome() ? f(this.value as any) : defFn();
}

/**
Expand Down Expand Up @@ -212,10 +212,10 @@ export class OptionLike<T> {
* ```
*
* @param {() => Err} fn
* @returns {(Ok<T> | Err)}
* @returns {(Ok<NonNullable<T>> | Err)}
* @memberof OptionLike
*/
public okOrElse(err: () => Err): Ok<T> | Err {
public okOrElse(err: () => Err): Ok<NonNullable<T>> | Err {
return this.isSome() ? Ok(this.value) : err();
}

Expand Down

0 comments on commit bfed50b

Please sign in to comment.