@@ -533,11 +533,11 @@ pub fn parse_ts_type_ref<'a, P: Parser<'a>>(p: &mut P) -> PResult<TsTypeRef> {
533
533
feature = "tracing-spans" ,
534
534
tracing:: instrument( level = "debug" , skip_all)
535
535
) ]
536
- pub fn parse_ts_type_ann < ' a , P : Parser < ' a > > (
536
+ pub ( super ) fn parse_ts_type_ann < ' a , P : Parser < ' a > > (
537
537
p : & mut P ,
538
538
eat_colon : bool ,
539
539
start : BytePos ,
540
- ) -> PResult < Box < TsTypeAnn > > {
540
+ ) -> PResult < TsTypeAnn > {
541
541
trace_cur ! ( p, parse_ts_type_ann) ;
542
542
543
543
debug_assert ! ( p. input( ) . syntax( ) . typescript( ) ) ;
@@ -551,10 +551,10 @@ pub fn parse_ts_type_ann<'a, P: Parser<'a>>(
551
551
552
552
let type_ann = parse_ts_type ( p) ?;
553
553
554
- Ok ( Box :: new ( TsTypeAnn {
554
+ Ok ( TsTypeAnn {
555
555
span : p. span ( start) ,
556
556
type_ann,
557
- } ) )
557
+ } )
558
558
} )
559
559
}
560
560
@@ -570,10 +570,10 @@ pub fn parse_ts_this_type_predicate<'a, P: Parser<'a>>(
570
570
let param_name = TsThisTypeOrIdent :: TsThisType ( lhs) ;
571
571
let type_ann = if p. input_mut ( ) . eat ( & P :: Token :: IS ) {
572
572
let cur_pos = p. input_mut ( ) . cur_pos ( ) ;
573
- Some ( parse_ts_type_ann (
573
+ Some ( Box :: new ( parse_ts_type_ann (
574
574
p, // eat_colon
575
575
false , cur_pos,
576
- ) ?)
576
+ ) ?) )
577
577
} else {
578
578
None
579
579
} ;
@@ -823,17 +823,21 @@ pub fn parse_ts_type_or_type_predicate_ann<'a, P: Parser<'a>>(
823
823
// eat_colon
824
824
false ,
825
825
return_token_start,
826
- ) ;
826
+ )
827
+ . map ( Box :: new) ;
827
828
}
828
829
829
830
let type_pred_var = parse_ident_name ( p) ?;
830
831
let type_ann = if has_type_pred_is {
831
832
p. assert_and_bump ( & P :: Token :: IS ) ;
832
833
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
+ )
837
841
} else {
838
842
None
839
843
} ;
@@ -921,17 +925,19 @@ fn try_parse_ts_type<'a, P: Parser<'a>>(p: &mut P) -> PResult<Option<Box<TsType>
921
925
feature = "tracing-spans" ,
922
926
tracing:: instrument( level = "debug" , skip_all)
923
927
) ]
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 > > > {
925
931
if !cfg ! ( feature = "typescript" ) {
926
932
return Ok ( None ) ;
927
933
}
928
934
929
935
if p. input_mut ( ) . is ( & P :: Token :: COLON ) {
930
936
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 )
932
940
}
933
-
934
- Ok ( None )
935
941
}
936
942
937
943
/// `tsNextThenParseType`
@@ -1298,7 +1304,7 @@ pub fn try_parse_ts_index_signature<'a, P: Parser<'a>>(
1298
1304
1299
1305
let type_ann = parse_ts_type_ann ( p, /* eat_colon */ false , type_ann_start) ?;
1300
1306
id. span = p. span ( ident_start) ;
1301
- id. type_ann = Some ( type_ann) ;
1307
+ id. type_ann = Some ( Box :: new ( type_ann) ) ;
1302
1308
1303
1309
expect ! ( p, & P :: Token :: RBRACKET ) ;
1304
1310
0 commit comments