From e40b83f3162f62b1f20d2c2b40da71d67c11aa58 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Tue, 7 Jan 2025 12:17:46 -0800 Subject: [PATCH] [flow] Flip default of `module.system.haste.module_ref_prefix.standard_cjs_esm_interop` and remove ability to set it to false Summary: Changelog: [internal] Reviewed By: panagosg7 Differential Revision: D67867385 ------------------------------------------------------------------------ (from 8033601db9ea3eff9a99816b9d801a7f75a75f9b) fbshipit-source-id: 1ebcdcb7d6e11c6a2b7b21b7c412ae6ba8776d34 --- src/commands/commandUtils.ml | 2 -- src/commands/config/flowConfig.ml | 13 +++++++------ src/commands/config/flowConfig.mli | 2 -- src/common/options.ml | 4 ---- src/flow_dot_js.ml | 1 - .../__tests__/refactor_extract_utils_tests.ml | 1 - src/typing/__tests__/type_hint_test.ml | 1 - src/typing/__tests__/typed_ast_test.ml | 1 - src/typing/context.ml | 6 ------ src/typing/context.mli | 3 --- src/typing/flow_js_utils.ml | 2 +- src/typing/statement.ml | 2 +- src/typing/type_sig_merge.ml | 9 +-------- .../.flowconfig | 1 - 14 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/commands/commandUtils.ml b/src/commands/commandUtils.ml index 3f396e58b97..604334c9fba 100644 --- a/src/commands/commandUtils.ml +++ b/src/commands/commandUtils.ml @@ -1416,8 +1416,6 @@ let make_options || FlowConfig.include_warnings flowconfig; opt_max_header_tokens = FlowConfig.max_header_tokens flowconfig; opt_haste_module_ref_prefix = FlowConfig.haste_module_ref_prefix flowconfig; - opt_haste_module_ref_prefix_standard_cjs_esm_interop = - FlowConfig.haste_module_ref_prefix_standard_cjs_esm_interop flowconfig; opt_haste_module_ref_prefix_LEGACY_INTEROP = FlowConfig.haste_module_ref_prefix_LEGACY_INTEROP flowconfig; opt_haste_name_reducers = FlowConfig.haste_name_reducers flowconfig; diff --git a/src/commands/config/flowConfig.ml b/src/commands/config/flowConfig.ml index 0d8de0db7a4..c7c3cfd5302 100644 --- a/src/commands/config/flowConfig.ml +++ b/src/commands/config/flowConfig.ml @@ -82,7 +82,6 @@ module Opts = struct gc_worker_space_overhead: int option; (** Gc.control's space_overhead *) gc_worker_window_size: int option; (** Gc.control's window_size *) haste_module_ref_prefix: string option; - haste_module_ref_prefix_standard_cjs_esm_interop: bool; haste_module_ref_prefix_LEGACY_INTEROP: string option; haste_name_reducers: (Str.regexp * string) list; haste_namespaces: string list; @@ -218,7 +217,6 @@ module Opts = struct gc_worker_space_overhead = None; gc_worker_window_size = None; haste_module_ref_prefix = None; - haste_module_ref_prefix_standard_cjs_esm_interop = false; haste_module_ref_prefix_LEGACY_INTEROP = None; haste_name_reducers = [(Str.regexp "^\\(.*/\\)?\\([a-zA-Z0-9$_.-]+\\)\\.js\\(\\.flow\\)?$", "\\2")]; @@ -1057,7 +1055,13 @@ module Opts = struct ("module.system", module_system_parser); ("module.system.haste.module_ref_prefix", haste_module_ref_prefix_parser); ( "module.system.haste.module_ref_prefix.standard_cjs_esm_interop", - boolean (fun opts v -> Ok { opts with haste_module_ref_prefix_standard_cjs_esm_interop = v }) + boolean (fun opts v -> + if v then + Ok opts + else + Error + "module.system.haste.module_ref_prefix.standard_cjs_esm_interop cannot be disabled." + ) ); ( "module.system.haste.module_ref_prefix_LEGACY_INTEROP", haste_module_ref_prefix_LEGACY_INTEROP_parser @@ -1732,9 +1736,6 @@ let gc_worker_window_size c = c.options.Opts.gc_worker_window_size let haste_module_ref_prefix c = c.options.Opts.haste_module_ref_prefix -let haste_module_ref_prefix_standard_cjs_esm_interop c = - c.options.Opts.haste_module_ref_prefix_standard_cjs_esm_interop - let haste_module_ref_prefix_LEGACY_INTEROP c = c.options.Opts.haste_module_ref_prefix_LEGACY_INTEROP let haste_name_reducers c = c.options.Opts.haste_name_reducers diff --git a/src/commands/config/flowConfig.mli b/src/commands/config/flowConfig.mli index a275affc35a..6b3439b74fc 100644 --- a/src/commands/config/flowConfig.mli +++ b/src/commands/config/flowConfig.mli @@ -142,8 +142,6 @@ val gc_worker_window_size : config -> int option val haste_module_ref_prefix : config -> string option -val haste_module_ref_prefix_standard_cjs_esm_interop : config -> bool - val haste_module_ref_prefix_LEGACY_INTEROP : config -> string option val haste_name_reducers : config -> (Str.regexp * string) list diff --git a/src/common/options.ml b/src/common/options.ml index 45ca88e3e0c..a33b317e951 100644 --- a/src/common/options.ml +++ b/src/common/options.ml @@ -104,7 +104,6 @@ type t = { opt_format: format; opt_gc_worker: gc_control; opt_haste_module_ref_prefix: string option; - opt_haste_module_ref_prefix_standard_cjs_esm_interop: bool; opt_haste_module_ref_prefix_LEGACY_INTEROP: string option; opt_haste_name_reducers: (Str.regexp * string) list; opt_haste_namespaces_options: Haste_namespaces.options; @@ -256,9 +255,6 @@ let gc_worker opts = opts.opt_gc_worker let haste_module_ref_prefix opts = opts.opt_haste_module_ref_prefix -let haste_module_ref_prefix_standard_cjs_esm_interop opts = - opts.opt_haste_module_ref_prefix_standard_cjs_esm_interop - let haste_module_ref_prefix_LEGACY_INTEROP opts = opts.opt_haste_module_ref_prefix_LEGACY_INTEROP let haste_name_reducers opts = opts.opt_haste_name_reducers diff --git a/src/flow_dot_js.ml b/src/flow_dot_js.ml index 1669f196671..6a2e1b7f1f4 100644 --- a/src/flow_dot_js.ml +++ b/src/flow_dot_js.ml @@ -120,7 +120,6 @@ let stub_metadata ~root ~checked = facebook_fbt = None; facebook_module_interop = false; file_options = Files.default_options; - haste_module_ref_prefix_standard_cjs_esm_interop = false; ignore_non_literal_requires = false; max_literal_length = 100; max_workers = 0; diff --git a/src/services/code_action/__tests__/refactor_extract_utils_tests.ml b/src/services/code_action/__tests__/refactor_extract_utils_tests.ml index 2d0c4f63a7c..dd7751f507a 100644 --- a/src/services/code_action/__tests__/refactor_extract_utils_tests.ml +++ b/src/services/code_action/__tests__/refactor_extract_utils_tests.ml @@ -53,7 +53,6 @@ let stub_metadata ~root ~checked = facebook_fbt = None; facebook_module_interop = false; file_options; - haste_module_ref_prefix_standard_cjs_esm_interop = false; ignore_non_literal_requires = false; max_literal_length = 100; max_workers = 0; diff --git a/src/typing/__tests__/type_hint_test.ml b/src/typing/__tests__/type_hint_test.ml index 8f73b0943ec..ba4c7a25755 100644 --- a/src/typing/__tests__/type_hint_test.ml +++ b/src/typing/__tests__/type_hint_test.ml @@ -44,7 +44,6 @@ let metadata = facebook_fbt = None; facebook_module_interop = false; file_options = Files.default_options; - haste_module_ref_prefix_standard_cjs_esm_interop = false; ignore_non_literal_requires = false; max_literal_length = 100; max_workers = 0; diff --git a/src/typing/__tests__/typed_ast_test.ml b/src/typing/__tests__/typed_ast_test.ml index 8112301a415..041b320260d 100644 --- a/src/typing/__tests__/typed_ast_test.ml +++ b/src/typing/__tests__/typed_ast_test.ml @@ -42,7 +42,6 @@ let metadata = facebook_fbt = None; facebook_module_interop = false; file_options = Files.default_options; - haste_module_ref_prefix_standard_cjs_esm_interop = false; ignore_non_literal_requires = false; max_literal_length = 100; max_workers = 0; diff --git a/src/typing/context.ml b/src/typing/context.ml index cbe1435cc5c..083b237b9ec 100644 --- a/src/typing/context.ml +++ b/src/typing/context.ml @@ -53,7 +53,6 @@ type metadata = { facebook_fbt: string option; facebook_module_interop: bool; file_options: Files.options; - haste_module_ref_prefix_standard_cjs_esm_interop: bool; ignore_non_literal_requires: bool; max_literal_length: int; max_workers: int; @@ -280,8 +279,6 @@ let metadata_of_options options = facebook_fbt = Options.facebook_fbt options; facebook_module_interop = Options.facebook_module_interop options; file_options = Options.file_options options; - haste_module_ref_prefix_standard_cjs_esm_interop = - Options.haste_module_ref_prefix_standard_cjs_esm_interop options; ignore_non_literal_requires = Options.should_ignore_non_literal_requires options; max_literal_length = Options.max_literal_length options; max_workers = Options.max_workers options; @@ -634,9 +631,6 @@ let verbose cx = cx.metadata.verbose let slow_to_check_logging cx = cx.metadata.slow_to_check_logging -let haste_module_ref_prefix_standard_cjs_esm_interop cx = - cx.metadata.haste_module_ref_prefix_standard_cjs_esm_interop - let max_workers cx = cx.metadata.max_workers let missing_module_generators cx = cx.metadata.missing_module_generators diff --git a/src/typing/context.mli b/src/typing/context.mli index ec09faea5c5..21dba182722 100644 --- a/src/typing/context.mli +++ b/src/typing/context.mli @@ -97,7 +97,6 @@ type metadata = { facebook_fbt: string option; facebook_module_interop: bool; file_options: Files.options; - haste_module_ref_prefix_standard_cjs_esm_interop: bool; ignore_non_literal_requires: bool; max_literal_length: int; max_workers: int; @@ -297,8 +296,6 @@ val verbose : t -> Verbose.t option val slow_to_check_logging : t -> Slow_to_check_logging.t -val haste_module_ref_prefix_standard_cjs_esm_interop : t -> bool - val max_workers : t -> int val missing_module_generators : t -> (Str.regexp * string) list diff --git a/src/typing/flow_js_utils.ml b/src/typing/flow_js_utils.ml index 0973d183c8e..8c3e6518b1e 100644 --- a/src/typing/flow_js_utils.ml +++ b/src/typing/flow_js_utils.ml @@ -1559,7 +1559,7 @@ module CJSRequireTKit = struct NamespaceT { namespace_symbol = module_symbol; values_type; types_tmap } in let t = - if standard_cjs_esm_interop then + if standard_cjs_esm_interop && not legacy_interop then lookup_builtin_typeapp cx reason diff --git a/src/typing/statement.ml b/src/typing/statement.ml index aa9dfbbfc0f..4039adc7e9a 100644 --- a/src/typing/statement.ml +++ b/src/typing/statement.ml @@ -829,7 +829,7 @@ module Make cx (mk_reason (RModule mref) loc) ~namespace_symbol:(mk_module_symbol ~name:mref ~def_loc:loc) - ~standard_cjs_esm_interop:(Context.haste_module_ref_prefix_standard_cjs_esm_interop cx) + ~standard_cjs_esm_interop:true ~legacy_interop module_t in diff --git a/src/typing/type_sig_merge.ml b/src/typing/type_sig_merge.ml index ca330763df6..c1ea3e7b03f 100644 --- a/src/typing/type_sig_merge.ml +++ b/src/typing/type_sig_merge.ml @@ -538,14 +538,7 @@ let rec merge ?(hooklike = false) ?(as_const = false) ?(const_decl = false) env let t = Flow_js_utils.lookup_builtin_typeapp file.cx reason "Promise" [ns_t] in make_hooklike file hooklike t | Pack.ModuleRef { loc; index; legacy_interop } -> - let t = - require - file - loc - index - ~standard_cjs_esm_interop:(Context.haste_module_ref_prefix_standard_cjs_esm_interop file.cx) - ~legacy_interop - in + let t = require file loc index ~standard_cjs_esm_interop:true ~legacy_interop in let reason = Reason.(mk_reason (RCustom "module reference") loc) in let t = Flow_js_utils.lookup_builtin_typeapp file.cx reason "$Flow$ModuleRef" [t] in make_hooklike file hooklike t diff --git a/tests/haste_module_ref_standard_cjs_esm_interop/.flowconfig b/tests/haste_module_ref_standard_cjs_esm_interop/.flowconfig index 1ce6ff52d8a..9c701462004 100644 --- a/tests/haste_module_ref_standard_cjs_esm_interop/.flowconfig +++ b/tests/haste_module_ref_standard_cjs_esm_interop/.flowconfig @@ -2,4 +2,3 @@ all=true module.system=haste module.system.haste.module_ref_prefix=m# -module.system.haste.module_ref_prefix.standard_cjs_esm_interop=true