File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export interface IMaybe<T> extends IMonad<T> {
7676 /**
7777 * Map output of non-empty data to a new value
7878 */
79- map < R > ( f : ( t : T ) => R ) : IMaybe < R >
79+ map < R > ( f : ( t : T ) => NonNullable < R > ) : IMaybe < R >
8080
8181 /**
8282 * Returns true if value is not empty
Original file line number Diff line number Diff line change @@ -199,14 +199,15 @@ describe('Maybe', () => {
199199 const maybeNotSomeSome2 = maybe ( sut )
200200 . map ( _str => getUserService < string > ( 0 ) )
201201 . valueOr ( 'fallback' )
202+
202203 const maybeNotSomeSome3 = maybe ( sut )
203- . map ( _str => getUserService < string > ( '' ) )
204+ . map ( _str => 'sut' )
204205 . valueOr ( 'fallback' )
205206
206207 expect ( maybeSomeString ) . toEqual ( 'initial input mapped' )
207208 expect ( maybeNotSomeSomeString ) . toEqual ( 'fallback' )
208209 expect ( maybeNotSomeSome2 ) . toEqual ( 0 )
209- expect ( maybeNotSomeSome3 ) . toEqual ( '' )
210+ expect ( maybeNotSomeSome3 ) . toEqual ( 'sut ' )
210211 } )
211212
212213 it ( 'should handle undefined input' , ( ) => {
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export class Maybe<T> implements IMaybe<T> {
7474 : [ this . value as NonNullable < T > ]
7575 }
7676
77- public map < R > ( fn : ( t : NonNullable < T > ) => R ) : IMaybe < R > {
77+ public map < R > ( fn : ( t : NonNullable < T > ) => NonNullable < R > ) : IMaybe < R > {
7878 return this . isSome ( )
7979 ? new Maybe < R > ( fn ( this . value as NonNullable < T > ) )
8080 : new Maybe < R > ( )
@@ -98,7 +98,7 @@ export class Maybe<T> implements IMaybe<T> {
9898 : new Maybe < T > ( )
9999 }
100100
101- public apply < R > ( fab : IMaybe < ( v : T ) => R > ) : IMaybe < R > {
101+ public apply < R > ( fab : IMaybe < ( v : T ) => NonNullable < R > > ) : IMaybe < R > {
102102 return this . flatMap ( b => fab . map ( fn => fn ( b ) ) )
103103 }
104104}
You can’t perform that action at this time.
0 commit comments