@@ -474,24 +474,29 @@ let infer_type filename content line col js_config_object : Loc.t * (string, str
474
474
let (cx, typed_ast) = infer_and_merge ~root filename js_config_object docblock ast file_sig in
475
475
let loc = mk_loc filename line col in
476
476
let open Query_types in
477
- let result =
478
- type_at_pos_type
479
- ~cx
480
- ~file_sig
481
- ~omit_targ_defaults: false
482
- ~typed_ast
483
- ~verbose_normalizer: false
484
- ~max_depth: 50
485
- ~no_typed_ast_for_imports: false
486
- loc
487
- in
488
- begin
489
- match result with
490
- | FailureNoMatch -> (Loc. none, Error " No match" )
491
- | FailureUnparseable (loc , _ , _ ) -> (loc, Error " Unparseable" )
492
- | Success (loc , result ) ->
493
- (loc, Ok (Ty_printer. string_of_type_at_pos_result ~exact_by_default: true result))
494
- end
477
+ if Js.Unsafe. get js_config_object " dev_only.type_repr" |> Js. to_bool then
478
+ match dump_type_at_pos ~cx ~typed_ast loc with
479
+ | None -> (Loc. none, Error " No match" )
480
+ | Some (loc , s ) -> (loc, Ok (Utils_js. spf " type_repr: %s" s))
481
+ else
482
+ let result =
483
+ type_at_pos_type
484
+ ~cx
485
+ ~file_sig
486
+ ~omit_targ_defaults: false
487
+ ~typed_ast
488
+ ~verbose_normalizer: false
489
+ ~max_depth: 50
490
+ ~no_typed_ast_for_imports: false
491
+ loc
492
+ in
493
+ begin
494
+ match result with
495
+ | FailureNoMatch -> (Loc. none, Error " No match" )
496
+ | FailureUnparseable (loc , _ , _ ) -> (loc, Error " Unparseable" )
497
+ | Success (loc , result ) ->
498
+ (loc, Ok (Ty_printer. string_of_type_at_pos_result ~exact_by_default: true result))
499
+ end
495
500
496
501
let signature_help filename content line col js_config_object :
497
502
((ServerProt.Response. func_details_result list * int ) option , string ) result =
@@ -802,6 +807,13 @@ let () =
802
807
" default" : false ,
803
808
" desc" : " Changes the default type of 'catch' variables from 'any' to 'mixed'."
804
809
},
810
+ {
811
+ " key" : " dev_only.type_repr" ,
812
+ " kind" : " option" ,
813
+ " type" : " bool" ,
814
+ " default" : false ,
815
+ " desc" : " Show the underlying type representation for debugging purposes."
816
+ },
805
817
{
806
818
" key" : " deprecated-type" ,
807
819
" kind" : " lint" ,
0 commit comments