Skip to content

Commit 3fc2a43

Browse files
avikchaudhurifacebook-github-bot
authored andcommitted
kill weak mode
Summary: flow weak was designed to mimic TypeScript, in that missing annotations would be treated as any instead of implicitly static types that can be inferred. It's not been maintained for a while, so any continued use probably detracts from the Flow experience while not giving a good TypeScript experience either. TODO: update docs Reviewed By: jeffmo Differential Revision: D4475119 fbshipit-source-id: 7d912f14155a0396fc61fa810650d34506236aa9
1 parent 032bfe6 commit 3fc2a43

12 files changed

Lines changed: 4 additions & 54 deletions

File tree

src/flow_dot_js.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ let stub_metadata ~root ~checked = { Context.
9393
suppress_comments = [];
9494
suppress_types = SSet.empty;
9595
verbose = None;
96-
weak = false;
9796
jsx = None;
9897
}
9998

src/parsing/docblock.ml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
module Ast = Spider_monkey_ast
1212
module Lex_result = Lexer_flow.Lex_result
1313

14-
type flow_mode = OptIn | OptInWeak | OptOut
14+
type flow_mode = OptIn | OptOut
1515

1616
type t = {
1717
flow: flow_mode option;
@@ -44,11 +44,6 @@ let extract : max_tokens:int -> Loc.filename -> string -> error list * t =
4444
if @flow or @providesModule is found more than once, the first one is used
4545
and an error is returned. *)
4646
let rec parse_attributes (errors, info) = function
47-
| (loc, "@flow") :: (_, "weak") :: xs ->
48-
let acc =
49-
if info.flow <> None then (loc, MultipleFlowAttributes)::errors, info
50-
else errors, { info with flow = Some OptInWeak } in
51-
parse_attributes acc xs
5247
| (loc, "@flow") :: xs ->
5348
let acc =
5449
if info.flow <> None then (loc, MultipleFlowAttributes)::errors, info
@@ -201,8 +196,7 @@ let isDeclarationFile info = info.isDeclarationFile
201196
let jsx info = info.jsx
202197

203198
let is_flow info = match info.flow with
204-
| Some OptIn
205-
| Some OptInWeak -> true
199+
| Some OptIn -> true
206200
| Some OptOut
207201
| None -> false
208202

@@ -211,7 +205,6 @@ let json_of_docblock info =
211205
let open Hh_json in
212206
let flow = match flow info with
213207
| Some OptIn -> JSON_String "OptIn"
214-
| Some OptInWeak -> JSON_String "OptInWeak"
215208
| Some OptOut -> JSON_String "OptOut"
216209
| None -> JSON_Null in
217210

src/parsing/parsing_service_js.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ let do_parse ?(fail=true) ~types_mode ~use_strict ~info content file =
188188
begin match Docblock.flow info with
189189
| None
190190
| Some Docblock.OptOut -> false
191-
| Some Docblock.OptIn
192-
| Some Docblock.OptInWeak -> true
191+
| Some Docblock.OptIn -> true
193192
end
194193
in
195194
(* don't bother to parse if types are disabled *)

src/services/inference/infer_service.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ let apply_docblock_overrides metadata docblock_info =
1818
let metadata = match Docblock.flow docblock_info with
1919
| None -> metadata
2020
| Some Docblock.OptIn -> { metadata with checked = true; }
21-
| Some Docblock.OptInWeak -> { metadata with checked = true; weak = true }
2221

2322
(* --all (which sets metadata.checked = true) overrides @noflow, so there are
2423
currently no scenarios where we'd change checked = true to false. in the

src/services/inference/init_js.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ let get_master_cx, restore_master_cx =
3232
| None ->
3333
let metadata = Context.({ (metadata_of_options options) with
3434
checked = false;
35-
weak = false;
3635
}) in
3736
let cx = Flow.fresh_context
3837
metadata Loc.Builtins (Modulename.String Files.lib_module) in
@@ -99,7 +98,6 @@ let load_lib_files ~options files =
9998

10099
let metadata = Context.({ (metadata_of_options options) with
101100
checked = false;
102-
weak = false;
103101
}) in
104102

105103
let cx, syms = Infer.infer_lib_file

src/typing/context.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type metadata = {
3131
suppress_comments: Str.regexp list;
3232
suppress_types: SSet.t;
3333
verbose: Verbose.t option;
34-
weak: bool;
3534
max_workers: int;
3635
jsx: (string * Spider_monkey_ast.Expression.t) option;
3736
}
@@ -126,7 +125,6 @@ let metadata_of_options options = {
126125
suppress_comments = Options.suppress_comments options;
127126
suppress_types = Options.suppress_types options;
128127
verbose = Options.verbose options;
129-
weak = Options.weak_by_default options;
130128
max_workers = Options.max_workers options;
131129
jsx = None;
132130
}
@@ -199,7 +197,6 @@ let import_stmts cx = cx.import_stmts
199197
let imported_ts cx = cx.imported_ts
200198
let is_checked cx = cx.metadata.checked
201199
let is_verbose cx = cx.metadata.verbose <> None
202-
let is_weak cx = cx.metadata.weak
203200
let max_trace_depth cx = cx.metadata.max_trace_depth
204201
let module_kind cx = cx.module_kind
205202
let module_map cx = cx.modulemap

src/typing/context.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type metadata = {
3030
suppress_comments: Str.regexp list;
3131
suppress_types: SSet.t;
3232
verbose: Verbose.t option;
33-
weak: bool;
3433
max_workers: int;
3534
jsx: (string * Spider_monkey_ast.Expression.t) option;
3635
}
@@ -68,7 +67,6 @@ val import_stmts: t -> Spider_monkey_ast.Statement.ImportDeclaration.t list
6867
val imported_ts: t -> Type.t SMap.t
6968
val is_checked: t -> bool
7069
val is_verbose: t -> bool
71-
val is_weak: t -> bool
7270
val max_trace_depth: t -> int
7371
val module_kind: t -> module_kind
7472
val module_map: t -> Type.t SMap.t

src/typing/type_annotation.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,11 +683,7 @@ and mk_rest cx = function
683683

684684
and mk_type cx tparams_map reason = function
685685
| None ->
686-
let t =
687-
if Context.is_weak cx
688-
then AnyT.why reason
689-
else Flow_js.mk_tvar cx reason
690-
in
686+
let t = Flow_js.mk_tvar cx reason in
691687
Hashtbl.replace (Context.annot_table cx) (loc_of_reason reason) t;
692688
t
693689

tests/weakmode/.flowconfig

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/weakmode/should_fail_without_weak.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)