Skip to content

Commit ba78ab9

Browse files
noppafacebook-github-bot
authored andcommitted
[PR] Add $FlowIgnore to the suppression comments
Summary: Fixes #8392. Allow suppressing Flow errors with a $FlowIgnore comment. <!-- If this is a change to library defintions, please include links to relevant documentation. If this is a documentation change, please prefix the title with [DOCS]. If this is neither, ensure you opened a discussion issue and link it in the PR description. --> Pull Request resolved: #8397 Reviewed By: mroch Differential Revision: D21976788 Pulled By: dsainati1 fbshipit-source-id: 26426dd386d1045517f076c0f7aa4b06521b1b3b
1 parent 3a5e5db commit ba78ab9

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/typing/errors/suppression_comments.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
(*
99
Suppression comments have the following syntax:
1010
11-
<SUPPRESSOR> := $FlowIssue | $FlowFixMe | $FlowExpectedError
11+
<SUPPRESSOR> := $FlowIssue | $FlowFixMe | $FlowExpectedError | $FlowIgnore
1212
1313
//<SUPPRESSOR>[CODE]...
1414
*)
@@ -72,7 +72,7 @@ let should_suppress comment loc =
7272
let (comment, is_suppressor) =
7373
consume_tokens [" "; "\n"; "\t"; "\r"; "*"] comment
7474
|> fst
75-
|> consume_tokens ["$FlowFixMe"; "$FlowIssue"; "$FlowExpectedError"]
75+
|> consume_tokens ["$FlowFixMe"; "$FlowIssue"; "$FlowExpectedError"; "$FlowIgnore"]
7676
in
7777
if not is_suppressor then
7878
Ok None

tests/suppress_default/suppress_default.exp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
Error ----------------------------------------------------------------------------------------------------- test.js:28:2
1+
Error ----------------------------------------------------------------------------------------------------- test.js:31:2
22

33
Cannot cast `3` to string because number [1] is incompatible with string [2]. [incompatible-cast]
44

5-
test.js:28:2
6-
28| (3 : string); // error
5+
test.js:31:2
6+
31| (3 : string); // error
77
^ [1]
88

99
References:
10-
test.js:28:6
11-
28| (3 : string); // error
10+
test.js:31:6
11+
31| (3 : string); // error
1212
^^^^^^ [2]
1313

1414

tests/suppress_default/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
/* $FlowFixMe */
1313
(3 : string); // no error
1414

15+
/* $FlowIgnore */
16+
(3 : string); // no error
17+
1518
/** $FlowFixMe */
1619
(3 : string); // no error
1720

0 commit comments

Comments
 (0)