Skip to content

Commit

Permalink
[PR] Add $FlowIgnore to the suppression comments
Browse files Browse the repository at this point in the history
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
  • Loading branch information
noppa authored and facebook-github-bot committed Jun 10, 2020
1 parent 3a5e5db commit ba78ab9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/typing/errors/suppression_comments.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(*
Suppression comments have the following syntax:
<SUPPRESSOR> := $FlowIssue | $FlowFixMe | $FlowExpectedError
<SUPPRESSOR> := $FlowIssue | $FlowFixMe | $FlowExpectedError | $FlowIgnore
//<SUPPRESSOR>[CODE]...
*)
Expand Down Expand Up @@ -72,7 +72,7 @@ let should_suppress comment loc =
let (comment, is_suppressor) =
consume_tokens [" "; "\n"; "\t"; "\r"; "*"] comment
|> fst
|> consume_tokens ["$FlowFixMe"; "$FlowIssue"; "$FlowExpectedError"]
|> consume_tokens ["$FlowFixMe"; "$FlowIssue"; "$FlowExpectedError"; "$FlowIgnore"]
in
if not is_suppressor then
Ok None
Expand Down
10 changes: 5 additions & 5 deletions tests/suppress_default/suppress_default.exp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Error ----------------------------------------------------------------------------------------------------- test.js:28:2
Error ----------------------------------------------------------------------------------------------------- test.js:31:2

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

test.js:28:2
28| (3 : string); // error
test.js:31:2
31| (3 : string); // error
^ [1]

References:
test.js:28:6
28| (3 : string); // error
test.js:31:6
31| (3 : string); // error
^^^^^^ [2]


Expand Down
3 changes: 3 additions & 0 deletions tests/suppress_default/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/* $FlowFixMe */
(3 : string); // no error

/* $FlowIgnore */
(3 : string); // no error

/** $FlowFixMe */
(3 : string); // no error

Expand Down

0 comments on commit ba78ab9

Please sign in to comment.