Skip to content

Commit dace8f8

Browse files
SamChou19815meta-codesync[bot]
authored andcommitted
[flow] Make NominalT for CustomError behave more like OpenT during union optimization
Summary: This diff makes `NominalT` for custom error purposes behave more like OpenT. Notably, we will mark it as needing further concretization and can be flattened, so that it can participate in union optimizations. Changelog: [internal] Reviewed By: gkz Differential Revision: D86676840 fbshipit-source-id: 13b0a3818006ea87816d0b22a4876e6abae52117
1 parent f13fd6e commit dace8f8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/typing/flow_js_utils.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ let needs_resolution = function
246246
| UnionT _
247247
| OptionalT _
248248
| MaybeT _
249-
| AnnotT _ ->
249+
| AnnotT _
250+
| NominalT (_, { underlying_t = Nominal.CustomError _; _ }) ->
250251
true
251252
| _ -> false
252253

src/typing/type_mapper.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ let union_flatten =
3232
let void_t = VoidT.why_with_use_desc ~use_desc r in
3333
void_t :: flatten cx seen t
3434
| DefT (_, EmptyT) -> []
35+
| NominalT (_, { underlying_t = Nominal.CustomError { t; _ }; _ }) -> flatten cx seen t
3536
| EvalT { type_ = _; defer_use_t = TypeDestructorT (_, _, ValuesType); id } ->
3637
(match Eval.Map.find_opt id (Context.evaluated cx) with
3738
| Some cached_t -> flatten cx seen cached_t

0 commit comments

Comments
 (0)