@@ -915,50 +915,51 @@ export class OptClass<T> extends ConstructType<[T] | []> {
915915
916916 public decodeValue ( b : Pipe , t : Type ) : [ T ] | [ ] {
917917 if ( t instanceof NullClass ) {
918- return [ ] ;
919- } ;
918+ return [ ]
919+ }
920920 if ( t instanceof ReservedClass ) {
921- return [ ] ;
922- } ;
921+ return [ ]
922+ }
923923 const wireType = this . checkType ( t ) ;
924924 if ( wireType instanceof OptClass ) {
925925 switch ( safeReadUint8 ( b ) ) {
926- case 0 :
927- return [ ] ;
928- case 1 :
929- let checkpoint = b . save ( ) ;
930- try {
931- let v = this . _type . decodeValue ( b , wireType . _type )
932- return [ v ] ;
933- } catch ( e : any ) {
934- b . restore ( checkpoint ) ;
935- // skip value at wire type (to advance b)
936- let skipped = wireType . _type . decodeValue ( b , wireType . _type )
937- // retun none
938- return [ ] ;
939- } ;
940- default :
941- throw new Error ( 'Not an option value' ) ;
926+ case 0 :
927+ return [ ] ;
928+ case 1 : {
929+ const checkpoint = b . save ( ) ;
930+ try {
931+ const v = this . _type . decodeValue ( b , wireType . _type ) ;
932+ return [ v ] ;
933+ } catch ( e : any ) {
934+ b . restore ( checkpoint ) ;
935+ // skip value at wire type (to advance b)
936+ const skipped = wireType . _type . decodeValue ( b , wireType . _type ) ;
937+ // retun none
938+ return [ ] ;
939+ }
940+ }
941+ default :
942+ throw new Error ( 'Not an option value' ) ;
942943 }
943944 } else if ( this . _type instanceof NullClass || this . _type instanceof OptClass || this . _type instanceof ReservedClass ) {
944945 // this check corresponds to `not (null <: <t>)` in the spec
945946 // skip value at wire type (to advance b) and return "null", i.e. []
946- let skipped = wireType . decodeValue ( b , wireType ) ;
947+ const skipped = wireType . decodeValue ( b , wireType ) ;
947948 return [ ] ;
948949 } else {
949950 // try constituent type
950- let checkpoint = b . save ( ) ;
951+ const checkpoint = b . save ( ) ;
951952 try {
952- let v = this . _type . decodeValue ( b , wireType )
953- return [ v ] ;
953+ const v = this . _type . decodeValue ( b , wireType )
954+ return [ v ] ;
954955 } catch ( e : any ) {
955- // decoding failed, but this is opt, so return "null", i.e. []
956- b . restore ( checkpoint ) ;
957- // skip value at wire type (to advance b)
958- let skipped = wireType . decodeValue ( b , wireType )
959- // return "null"
960- return [ ] ;
961- } ;
956+ // decoding failed, but this is opt, so return "null", i.e. []
957+ b . restore ( checkpoint ) ;
958+ // skip value at wire type (to advance b)
959+ const skipped = wireType . decodeValue ( b , wireType )
960+ // return "null"
961+ return [ ] ;
962+ }
962963 }
963964 }
964965
0 commit comments