@@ -533,11 +533,11 @@ pub fn parse_ts_type_ref<'a, P: Parser<'a>>(p: &mut P) -> PResult<TsTypeRef> {
533533 feature = "tracing-spans" ,
534534 tracing:: instrument( level = "debug" , skip_all)
535535) ]
536- pub fn parse_ts_type_ann < ' a , P : Parser < ' a > > (
536+ pub ( super ) fn parse_ts_type_ann < ' a , P : Parser < ' a > > (
537537 p : & mut P ,
538538 eat_colon : bool ,
539539 start : BytePos ,
540- ) -> PResult < Box < TsTypeAnn > > {
540+ ) -> PResult < TsTypeAnn > {
541541 trace_cur ! ( p, parse_ts_type_ann) ;
542542
543543 debug_assert ! ( p. input( ) . syntax( ) . typescript( ) ) ;
@@ -551,10 +551,10 @@ pub fn parse_ts_type_ann<'a, P: Parser<'a>>(
551551
552552 let type_ann = parse_ts_type ( p) ?;
553553
554- Ok ( Box :: new ( TsTypeAnn {
554+ Ok ( TsTypeAnn {
555555 span : p. span ( start) ,
556556 type_ann,
557- } ) )
557+ } )
558558 } )
559559}
560560
@@ -570,10 +570,10 @@ pub fn parse_ts_this_type_predicate<'a, P: Parser<'a>>(
570570 let param_name = TsThisTypeOrIdent :: TsThisType ( lhs) ;
571571 let type_ann = if p. input_mut ( ) . eat ( & P :: Token :: IS ) {
572572 let cur_pos = p. input_mut ( ) . cur_pos ( ) ;
573- Some ( parse_ts_type_ann (
573+ Some ( Box :: new ( parse_ts_type_ann (
574574 p, // eat_colon
575575 false , cur_pos,
576- ) ?)
576+ ) ?) )
577577 } else {
578578 None
579579 } ;
@@ -823,17 +823,21 @@ pub fn parse_ts_type_or_type_predicate_ann<'a, P: Parser<'a>>(
823823 // eat_colon
824824 false ,
825825 return_token_start,
826- ) ;
826+ )
827+ . map ( Box :: new) ;
827828 }
828829
829830 let type_pred_var = parse_ident_name ( p) ?;
830831 let type_ann = if has_type_pred_is {
831832 p. assert_and_bump ( & P :: Token :: IS ) ;
832833 let pos = p. input_mut ( ) . cur_pos ( ) ;
833- Some ( parse_ts_type_ann (
834- p, // eat_colon
835- false , pos,
836- ) ?)
834+ Some (
835+ parse_ts_type_ann (
836+ p, // eat_colon
837+ false , pos,
838+ )
839+ . map ( Box :: new) ?,
840+ )
837841 } else {
838842 None
839843 } ;
@@ -921,17 +925,19 @@ fn try_parse_ts_type<'a, P: Parser<'a>>(p: &mut P) -> PResult<Option<Box<TsType>
921925 feature = "tracing-spans" ,
922926 tracing:: instrument( level = "debug" , skip_all)
923927) ]
924- pub fn try_parse_ts_type_ann < ' a , P : Parser < ' a > > ( p : & mut P ) -> PResult < Option < Box < TsTypeAnn > > > {
928+ pub ( super ) fn try_parse_ts_type_ann < ' a , P : Parser < ' a > > (
929+ p : & mut P ,
930+ ) -> PResult < Option < Box < TsTypeAnn > > > {
925931 if !cfg ! ( feature = "typescript" ) {
926932 return Ok ( None ) ;
927933 }
928934
929935 if p. input_mut ( ) . is ( & P :: Token :: COLON ) {
930936 let pos = p. cur_pos ( ) ;
931- return parse_ts_type_ann ( p, /* eat_colon */ true , pos) . map ( Some ) ;
937+ parse_ts_type_ann ( p, /* eat_colon */ true , pos) . map ( |t| Some ( Box :: new ( t) ) )
938+ } else {
939+ Ok ( None )
932940 }
933-
934- Ok ( None )
935941}
936942
937943/// `tsNextThenParseType`
@@ -1298,7 +1304,7 @@ pub fn try_parse_ts_index_signature<'a, P: Parser<'a>>(
12981304
12991305 let type_ann = parse_ts_type_ann ( p, /* eat_colon */ false , type_ann_start) ?;
13001306 id. span = p. span ( ident_start) ;
1301- id. type_ann = Some ( type_ann) ;
1307+ id. type_ann = Some ( Box :: new ( type_ann) ) ;
13021308
13031309 expect ! ( p, & P :: Token :: RBRACKET ) ;
13041310
0 commit comments