Skip to content

Commit db975fc

Browse files
gkzmeta-codesync[bot]
authored andcommitted
[flow][records] Add option for records support
Summary: Adds `experimental.records` option to gate records support. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D86251886 fbshipit-source-id: 467a1d518d3c20acf02047e3f466e78b1e24fe29
1 parent 3dde830 commit db975fc

10 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/commands/commandUtils.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,7 @@ let make_options
14421442
Base.Option.value ~default:false (FlowConfig.pattern_matching flowconfig);
14431443
opt_enable_pattern_matching_instance_patterns =
14441444
Base.Option.value ~default:false (FlowConfig.pattern_matching_instance_patterns flowconfig);
1445+
opt_enable_records = Base.Option.value ~default:false (FlowConfig.records flowconfig);
14451446
opt_enable_relay_integration = FlowConfig.relay_integration flowconfig;
14461447
opt_enable_custom_error = FlowConfig.enable_custom_error flowconfig;
14471448
opt_enabled_rollouts = FlowConfig.enabled_rollouts flowconfig;

src/commands/config/flowConfig.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ module Opts = struct
134134
react_ref_as_prop: Options.ReactRefAsProp.t;
135135
react_rules: Options.react_rules list;
136136
react_runtime: Options.react_runtime;
137+
records: bool option;
137138
recursion_limit: int;
138139
relay_integration: bool;
139140
relay_integration_esmodules: bool;
@@ -282,6 +283,7 @@ module Opts = struct
282283
react_ref_as_prop = Options.ReactRefAsProp.FullSupport;
283284
react_rules = [];
284285
react_runtime = Options.ReactRuntimeClassic;
286+
records = None;
285287
recursion_limit = 10000;
286288
relay_integration = false;
287289
relay_integration_esmodules = false;
@@ -1127,6 +1129,7 @@ module Opts = struct
11271129
)
11281130
);
11291131
("experimental.projects_path_mapping", projects_path_mapping_parser);
1132+
("experimental.records", boolean (fun opts v -> Ok { opts with records = Some v }));
11301133
("experimental.strict_es6_import_export", strict_es6_import_export_parser);
11311134
("experimental.ts_syntax", boolean (fun opts v -> Ok { opts with ts_syntax = v }));
11321135
( "experimental.ts_utility_syntax",
@@ -2033,6 +2036,8 @@ let react_rules c = c.options.Opts.react_rules
20332036

20342037
let react_runtime c = c.options.Opts.react_runtime
20352038

2039+
let records c = c.options.Opts.records
2040+
20362041
let recursion_limit c = c.options.Opts.recursion_limit
20372042

20382043
let relay_integration c = c.options.Opts.relay_integration

src/commands/config/flowConfig.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ val react_rules : config -> Options.react_rules list
250250

251251
val react_runtime : config -> Options.react_runtime
252252

253+
val records : config -> bool option
254+
253255
val recursion_limit : config -> int
254256

255257
val relay_integration : config -> bool

src/common/options.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ type t = {
122122
opt_enable_jest_integration: bool;
123123
opt_enable_pattern_matching: bool;
124124
opt_enable_pattern_matching_instance_patterns: bool;
125+
opt_enable_records: bool;
125126
opt_enable_relay_integration: bool;
126127
opt_enable_custom_error: bool;
127128
opt_enabled_rollouts: string SMap.t;
@@ -243,6 +244,8 @@ let enable_pattern_matching opts = opts.opt_enable_pattern_matching
243244
let enable_pattern_matching_instance_patterns opts =
244245
opts.opt_enable_pattern_matching_instance_patterns
245246

247+
let enable_records opts = opts.opt_enable_records
248+
246249
let enable_relay_integration opts = opts.opt_enable_relay_integration
247250

248251
let enable_custom_error opts = opts.opt_enable_custom_error

src/flow_dot_js.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ let stub_metadata ~root ~checked =
115115
enable_jest_integration = false;
116116
enable_pattern_matching = true;
117117
enable_pattern_matching_instance_patterns = true;
118+
enable_records = true;
118119
enable_relay_integration = false;
119120
exact_by_default = true;
120121
facebook_fbs = None;

src/services/code_action/__tests__/refactor_extract_utils_tests.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ let stub_metadata ~root ~checked =
4444
enable_jest_integration = false;
4545
enable_pattern_matching = false;
4646
enable_pattern_matching_instance_patterns = false;
47+
enable_records = false;
4748
enable_relay_integration = false;
4849
exact_by_default = false;
4950
facebook_fbs = None;

src/typing/__tests__/type_hint_test.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ let metadata =
3939
enable_jest_integration = false;
4040
enable_pattern_matching = false;
4141
enable_pattern_matching_instance_patterns = false;
42+
enable_records = false;
4243
enable_relay_integration = false;
4344
exact_by_default = true;
4445
facebook_fbs = None;

src/typing/__tests__/typed_ast_test.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ let metadata =
3737
enable_jest_integration = false;
3838
enable_pattern_matching = false;
3939
enable_pattern_matching_instance_patterns = false;
40+
enable_records = false;
4041
enable_relay_integration = false;
4142
exact_by_default = false;
4243
facebook_fbs = None;

src/typing/context.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type metadata = {
4848
enable_jest_integration: bool;
4949
enable_pattern_matching: bool;
5050
enable_pattern_matching_instance_patterns: bool;
51+
enable_records: bool;
5152
enable_relay_integration: bool;
5253
exact_by_default: bool;
5354
facebook_fbs: string option;
@@ -307,6 +308,7 @@ let metadata_of_options options =
307308
enable_pattern_matching_instance_patterns =
308309
Options.enable_pattern_matching_instance_patterns options;
309310
pattern_matching_includes = Options.pattern_matching_includes options;
311+
enable_records = Options.enable_records options;
310312
enable_relay_integration = Options.enable_relay_integration options;
311313
exact_by_default = Options.exact_by_default options;
312314
facebook_fbs = Options.facebook_fbs options;
@@ -555,6 +557,8 @@ let enable_pattern_matching cx =
555557
let enable_pattern_matching_instance_patterns cx =
556558
cx.metadata.enable_pattern_matching_instance_patterns
557559

560+
let enable_records cx = cx.metadata.enable_records
561+
558562
let is_utility_type_deprecated cx t =
559563
match SMap.find_opt t cx.metadata.deprecated_utilities with
560564
| None -> false

src/typing/context.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type metadata = {
9898
enable_jest_integration: bool;
9999
enable_pattern_matching: bool;
100100
enable_pattern_matching_instance_patterns: bool;
101+
enable_records: bool;
101102
enable_relay_integration: bool;
102103
exact_by_default: bool;
103104
facebook_fbs: string option;
@@ -211,6 +212,8 @@ val enable_pattern_matching : t -> bool
211212

212213
val enable_pattern_matching_instance_patterns : t -> bool
213214

215+
val enable_records : t -> bool
216+
214217
val enable_relay_integration : t -> bool
215218

216219
val relay_integration_esmodules : t -> bool

0 commit comments

Comments
 (0)