From d2e7225229a86e9e31fd05cb4a6e6cc3722de2a3 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Wed, 20 Mar 2024 13:12:41 -0700 Subject: [PATCH] Back out most of D53969726 "[flow][refactor] Group post inference checks into post-component and post-merge" Summary: We never followed through on making these post inferences checks actually post component. Why didn't I finish that part? It's because some of the post inference checks after all components still needs to be performed, and might contain some stuff that's within some other components. Backing this out to avoid confusion and allow redesign. It's not a full backout, since I keep the change of colocating `detect_sketchy_null_checks` and `Exists_marker.mark cx tast;`, since they are supposed to be done together, and the exists marker is only useful for sketchy null checks. Changelog: [internal] Reviewed By: panagosg7 Differential Revision: D55143368 fbshipit-source-id: b7bdff658d8824f7085a2da32497aa8f6b71b044 --- src/typing/merge_js.ml | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/typing/merge_js.ml b/src/typing/merge_js.ml index b253ff45799..cc83b97e91a 100644 --- a/src/typing/merge_js.ml +++ b/src/typing/merge_js.ml @@ -577,38 +577,29 @@ let get_lint_severities metadata strict_mode lint_severities = else lint_severities -(* Post-component errors. - * - * At this point, all the types in the components we have checked so far should have been - * fully resolved, so we can freely inspect them and run some checks that are not relevant - * for deciding a type of a write. - *) -let post_component_checks cx = - check_polarity cx; - check_general_post_inference_validations cx; - validate_renders_type_arguments cx; - detect_unnecessary_optional_chains cx; - detect_unnecessary_invariants cx; - detect_unused_promises cx; - check_union_opt cx - (* Post-merge errors. * - * At this point, we have visited the entire typed-AST. - * - * Any constraints should have already been evaluated, which means we can complain about - * things that either haven't happened yet, or which require complete knowledge of tvar bounds. + * At this point, all dependencies have been merged and the component has been + * linked together. Any constraints should have already been evaluated, which + * means we can complain about things that either haven't happened yet, or + * which require complete knowledge of tvar bounds. *) let post_merge_checks cx ast tast metadata = - post_component_checks cx; check_react_rules cx tast; check_multiplatform_conformance cx ast tast; + check_polarity cx; + check_general_post_inference_validations cx; + validate_renders_type_arguments cx; detect_sketchy_null_checks cx tast; detect_non_voidable_properties cx; detect_test_prop_misses cx; + detect_unnecessary_optional_chains cx; + detect_unnecessary_invariants cx; detect_import_export_errors cx ast metadata; detect_matching_props_violations cx; - detect_literal_subtypes cx + detect_literal_subtypes cx; + detect_unused_promises cx; + check_union_opt cx (* Check will lazily create types for the checked file's dependencies. These * types are created in the dependency's context and need to be copied into the