@@ -50,31 +50,31 @@ describe('Result types', () => {
5050
5151 it ( 'should map value correctly' , ( ) => {
5252 const result = ok ( 5 )
53- const mapped = result . map ( x => x * 2 )
53+ const mapped = result . map ( ( x : number ) => x * 2 )
5454
5555 expect ( mapped . isOk ( ) ) . toBe ( true )
5656 expect ( mapped . unwrap ( ) ) . toBe ( 10 )
5757 } )
5858
5959 it ( 'should pass through mapErr' , ( ) => {
6060 const result = ok ( 5 )
61- const mapped = result . mapErr ( _e => new Error ( 'new error' ) )
61+ const mapped = result . mapErr ( ( _e : Error ) => new Error ( 'new error' ) )
6262
6363 expect ( mapped . isOk ( ) ) . toBe ( true )
6464 expect ( mapped . unwrap ( ) ) . toBe ( 5 )
6565 } )
6666
6767 it ( 'should chain andThen operations' , ( ) => {
6868 const result = ok ( 5 )
69- const chained = result . andThen ( x => ok ( x * 2 ) )
69+ const chained = result . andThen ( ( x : number ) => ok ( x * 2 ) )
7070
7171 expect ( chained . isOk ( ) ) . toBe ( true )
7272 expect ( chained . unwrap ( ) ) . toBe ( 10 )
7373 } )
7474
7575 it ( 'should handle andThen with error result' , ( ) => {
7676 const result = ok ( 5 )
77- const chained = result . andThen ( _x => err ( new Error ( 'failed' ) ) )
77+ const chained = result . andThen ( ( _x : number ) => err ( new Error ( 'failed' ) ) )
7878
7979 expect ( chained . isErr ( ) ) . toBe ( true )
8080 expect ( ( chained as Err < Error > ) . error ) . toEqual ( new Error ( 'failed' ) )
@@ -118,28 +118,30 @@ describe('Result types', () => {
118118 const result = err ( new Error ( 'failure' ) )
119119
120120 expect ( result . unwrapOr ( 42 ) ) . toBe ( 42 )
121- expect ( result . unwrapOrElse ( _e => _e . message . length ) ) . toBe ( 7 )
121+ expect ( result . unwrapOrElse ( ( _e : Error ) => _e . message . length ) ) . toBe ( 7 )
122122 } )
123123
124124 it ( 'should pass through map' , ( ) => {
125125 const result = err ( new Error ( 'failure' ) )
126- const mapped = result . map ( x => x * 2 )
126+ const mapped = result . map ( ( x : number ) => x * 2 )
127127
128128 expect ( mapped . isErr ( ) ) . toBe ( true )
129129 expect ( ( mapped as Err < Error > ) . error ) . toEqual ( new Error ( 'failure' ) )
130130 } )
131131
132132 it ( 'should map error correctly' , ( ) => {
133133 const result = err ( new Error ( 'original' ) )
134- const mapped = result . mapErr ( e => new Error ( 'mapped: ' + e . message ) )
134+ const mapped = result . mapErr (
135+ ( e : Error ) => new Error ( 'mapped: ' + e . message ) ,
136+ )
135137
136138 expect ( mapped . isErr ( ) ) . toBe ( true )
137139 expect ( ( mapped as Err < Error > ) . error . message ) . toBe ( 'mapped: original' )
138140 } )
139141
140142 it ( 'should pass through andThen' , ( ) => {
141143 const result = err ( new Error ( 'failure' ) )
142- const chained = result . andThen ( x => ok ( x * 2 ) )
144+ const chained = result . andThen ( ( x : number ) => ok ( x * 2 ) )
143145
144146 expect ( chained . isErr ( ) ) . toBe ( true )
145147 expect ( ( chained as Err < Error > ) . error ) . toEqual ( new Error ( 'failure' ) )
@@ -359,8 +361,8 @@ describe('PackageURL Result methods', () => {
359361 describe ( 'functional composition' , ( ) => {
360362 it ( 'should chain operations with map and andThen' , ( ) => {
361363 const result = PackageURL . tryFromString ( 'pkg:npm/[email protected] ' ) 362- . map ( purl => ( { purl, isNpm : purl . type === 'npm' } ) )
363- . andThen ( ( { isNpm, purl } ) =>
364+ . map ( ( purl : PackageURL ) => ( { purl, isNpm : purl . type === 'npm' } ) )
365+ . andThen ( ( { isNpm, purl } : { isNpm : boolean ; purl : PackageURL } ) =>
364366 isNpm ? ok ( purl . name ) : err ( new Error ( 'Not an npm package' ) ) ,
365367 )
366368
@@ -370,8 +372,8 @@ describe('PackageURL Result methods', () => {
370372
371373 it ( 'should handle error propagation' , ( ) => {
372374 const result = PackageURL . tryFromString ( 'invalid-purl' )
373- . map ( purl => purl . name )
374- . andThen ( name => ok ( name ?. toUpperCase ( ) ?? '' ) )
375+ . map ( ( purl : PackageURL ) => purl . name )
376+ . andThen ( ( name : string | undefined ) => ok ( name ?. toUpperCase ( ) ?? '' ) )
375377
376378 expect ( result . isErr ( ) ) . toBe ( true )
377379 } )
0 commit comments