File tree 4 files changed +20
-12
lines changed
4 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ class None_<A> implements Option<A> {
47
47
throw new Option . NoSuchElementError ( ) ;
48
48
}
49
49
50
- getOrElse < B , A extends B > ( this : None_ < A > , defaultValue : ( ) => B ) : B {
50
+ getOrElse < B , A extends B > ( this : Option < A > , defaultValue : ( ) => B ) : B {
51
51
return defaultValue ( ) ;
52
52
}
53
53
@@ -59,7 +59,7 @@ class None_<A> implements Option<A> {
59
59
return matcher . None ( ) ;
60
60
}
61
61
62
- orElse < B , A extends B > ( this : None_ < A > , alternative : ( ) => Option < B > ) : Option < B > {
62
+ orElse < B , A extends B > ( this : Option < A > , alternative : ( ) => Option < B > ) : Option < B > {
63
63
return alternative ( ) ;
64
64
}
65
65
}
Original file line number Diff line number Diff line change @@ -53,8 +53,10 @@ class Some<A> implements Option<A> {
53
53
return this . value ;
54
54
}
55
55
56
- getOrElse < B , A extends B > ( this : Some < A > , defaultValue : ( ) => B ) : B {
57
- return this . value ;
56
+ getOrElse < B , A extends B > ( this : Option < A > , defaultValue : ( ) => B ) : B {
57
+ const self : Some < A > = this as Some < A > ;
58
+
59
+ return self . value ;
58
60
}
59
61
60
62
map < B > ( mapper : ( value : A ) => B ) : Option < B > {
@@ -65,8 +67,10 @@ class Some<A> implements Option<A> {
65
67
return matcher . Some ( this . value ) ;
66
68
}
67
69
68
- orElse < B , A extends B > ( this : Some < A > , alternative : ( ) => Option < B > ) : Option < B > {
69
- return this ;
70
+ orElse < B , A extends B > ( this : Option < A > , alternative : ( ) => Option < B > ) : Option < B > {
71
+ const self : Some < A > = this as Some < A > ;
72
+
73
+ return self ;
70
74
}
71
75
}
72
76
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class Failure<A> implements Try<A> {
45
45
throw this . error ;
46
46
}
47
47
48
- getOrElse < B , A extends B > ( this : Failure < A > , defaultValue : ( ) => B ) : B {
48
+ getOrElse < B , A extends B > ( this : Try < A > , defaultValue : ( ) => B ) : B {
49
49
return defaultValue ( ) ;
50
50
}
51
51
@@ -57,7 +57,7 @@ class Failure<A> implements Try<A> {
57
57
return matcher . Failure ( this . error ) ;
58
58
}
59
59
60
- orElse < B , A extends B > ( this : Failure < A > , alternative : ( ) => Try < B > ) : Try < B > {
60
+ orElse < B , A extends B > ( this : Try < A > , alternative : ( ) => Try < B > ) : Try < B > {
61
61
return alternative ( ) ;
62
62
}
63
63
Original file line number Diff line number Diff line change @@ -46,8 +46,10 @@ class Success<A> implements Try<A> {
46
46
return this . value ;
47
47
}
48
48
49
- getOrElse < B , A extends B > ( this : Success < A > , defaultValue : ( ) => B ) : B {
50
- return this . value ;
49
+ getOrElse < B , A extends B > ( this : Try < A > , defaultValue : ( ) => B ) : B {
50
+ const self : Success < A > = this as Success < A > ;
51
+
52
+ return self . value ;
51
53
}
52
54
53
55
map < B > ( f : ( value : A ) => B ) : Try < B > {
@@ -58,8 +60,10 @@ class Success<A> implements Try<A> {
58
60
return matcher . Success ( this . value ) ;
59
61
}
60
62
61
- orElse < B , A extends B > ( this : Success < A > , alternative : ( ) => Try < B > ) : Try < B > {
62
- return this ;
63
+ orElse < B , A extends B > ( this : Try < A > , alternative : ( ) => Try < B > ) : Try < B > {
64
+ const self : Success < A > = this as Success < A > ;
65
+
66
+ return self ;
63
67
}
64
68
65
69
recover ( fn : ( error : Error ) => A ) : Try < A > {
You can’t perform that action at this time.
0 commit comments