File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,12 @@ describe("Option", () => {
5454 expect ( optionalObj . i ( 100 ) . type ) . toBe ( OptionType . None ) ;
5555 } ) ;
5656 it ( "can be called after k function" , ( ) => {
57- const obj = {
58- a : [ 0 , 1 , 2 ]
57+ type ArrObj = {
58+ a : number [ ]
59+ b ?: number [ ]
60+ }
61+ const obj : ArrObj = {
62+ a : [ 0 , 1 , 2 ] ,
5963 } ;
6064 const optionalObj = new Option ( obj ) ;
6165 expect (
@@ -70,6 +74,12 @@ describe("Option", () => {
7074 . i ( 1 )
7175 . get ( )
7276 ) . toBe ( 1 ) ;
77+ expect (
78+ optionalObj
79+ . k ( "b" )
80+ . i ( 0 )
81+ . get ( )
82+ ) . toBe ( undefined )
7383 } ) ;
7484 } ) ;
7585
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export class Option<T> {
5151}
5252
5353Option . prototype . i = function < U > ( index : number ) : Option < U > {
54- if ( this . value [ index ] === undefined ) {
54+ if ( this . value === undefined || this . value [ index ] === undefined ) {
5555 return new Option ( undefined as any ) ;
5656 }
5757 return new Option ( this . value [ index ] ) ;
You can’t perform that action at this time.
0 commit comments