@@ -201,9 +201,10 @@ end = struct
201201 loc, Type. Exists
202202 | T_LESS_THAN -> _function env
203203 | T_LPAREN -> function_or_group env
204- | T_LCURLY ->
205- let loc, o = _object env in
206- loc, Type. Object o
204+ | T_LCURLY
205+ | T_LCURLYBAR ->
206+ let loc, o = _object env ~allow_exact: true in
207+ loc, Type. Object o
207208 | T_TYPEOF ->
208209 let start_loc = Peek. loc env in
209210 Expect. token env T_TYPEOF ;
@@ -465,27 +466,35 @@ end = struct
465466 static;
466467 })
467468
468- in let semicolon env =
469+ in let semicolon exact env =
469470 match Peek. token env with
470471 | T_COMMA | T_SEMICOLON -> Eat. token env
471- | T_RCURLY -> ()
472+ | T_RCURLYBAR when exact -> ()
473+ | T_RCURLY when not exact -> ()
472474 | _ -> error_unexpected env
473475
474- in let rec properties ~allow_static env (acc , indexers , callProperties ) =
476+ in let rec properties ~allow_static ~exact env
477+ (acc , indexers , callProperties ) =
475478 let start_loc = Peek. loc env in
476479 let static = allow_static && Expect. maybe env T_STATIC in
477480 match Peek. token env with
478- | T_EOF
479- | T_RCURLY -> List. rev acc, List. rev indexers, List. rev callProperties
481+ | T_EOF ->
482+ List. rev acc, List. rev indexers, List. rev callProperties
483+ | T_RCURLYBAR when exact ->
484+ List. rev acc, List. rev indexers, List. rev callProperties
485+ | T_RCURLY when not exact ->
486+ List. rev acc, List. rev indexers, List. rev callProperties
480487 | T_LBRACKET ->
481488 let indexer = indexer_property env start_loc static in
482- semicolon env;
483- properties allow_static env (acc, indexer::indexers, callProperties)
489+ semicolon exact env;
490+ properties allow_static exact env
491+ (acc, indexer::indexers, callProperties)
484492 | T_LESS_THAN
485493 | T_LPAREN ->
486494 let call_prop = call_property env start_loc static in
487- semicolon env;
488- properties allow_static env (acc, indexers, call_prop::callProperties)
495+ semicolon exact env;
496+ properties allow_static exact env
497+ (acc, indexers, call_prop::callProperties)
489498 | _ ->
490499 let static, (_, key) = match static, Peek. token env with
491500 | true , T_COLON ->
@@ -507,17 +516,20 @@ end = struct
507516 | T_LESS_THAN
508517 | T_LPAREN -> method_property env start_loc static key
509518 | _ -> property env start_loc static key in
510- semicolon env;
511- properties allow_static env (property::acc, indexers, callProperties)
519+ semicolon exact env;
520+ properties allow_static exact env
521+ (property::acc, indexers, callProperties)
512522
513- in fun ?(allow_static =false ) env ->
523+ in fun ?(allow_static =false ) ?(allow_exact =false ) env ->
524+ let exact = allow_exact && Peek. token env = T_LCURLYBAR in
514525 let start_loc = Peek. loc env in
515- Expect. token env T_LCURLY ;
526+ Expect. token env ( if exact then T_LCURLYBAR else T_LCURLY ) ;
516527 let properties, indexers, callProperties =
517- properties ~allow_static env ([] , [] , [] ) in
528+ properties ~allow_static ~exact env ([] , [] , [] ) in
518529 let end_loc = Peek. loc env in
519- Expect. token env T_RCURLY ;
530+ Expect. token env ( if exact then T_RCURLYBAR else T_RCURLY ) ;
520531 Loc. btwn start_loc end_loc, Type.Object. ({
532+ exact;
521533 properties;
522534 indexers;
523535 callProperties
@@ -644,7 +656,8 @@ end = struct
644656 let type_parameter_declaration =
645657 wrap (type_parameter_declaration ~allow_default: false )
646658 let type_parameter_instantiation = wrap type_parameter_instantiation
647- let _object ?(allow_static =false ) env = wrap (_object ~allow_static ) env
659+ let _object ?(allow_static =false ) env =
660+ wrap (_object ~allow_static ~allow_exact: false ) env
648661 let function_param_list = wrap function_param_list
649662 let annotation = wrap annotation
650663 let annotation_opt = wrap annotation_opt
0 commit comments