-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Type dependencies are different than value ones. For example the import of `foo` in ``` // file b.js import {foo} from 'a'; foo(); module.exports = class A {}; ``` does not affect the type signature of file a.js since it does not affect its exports' type. The edge ``` a.js --> b.js ``` is only a value dependency but not a type one. This affects the behavior of `flow cycle` in that a cycle computed based on type dependencies only might differ from one that accounts for both. In Flow classic mode we took all dependencies into account to compute `flow cycle`. This behavior had regressed in types-first since `flow cycle` only accounted for type dependencies. This change restores the behavior for the default case of this command, and also adds an option `--types` to only account for type dependencies when computing cycles. In addressing performance issues due to cycles in types-first, one should try to break type-dependencies instead of the combination of the two. Reviewed By: gabelevi Differential Revision: D16018435 fbshipit-source-id: c059bc480be536e7185c8e92f8bc52cc3944c8b4
- Loading branch information
1 parent
7397086
commit d7e7e78
Showing
9 changed files
with
95 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[lints] | ||
|
||
[options] | ||
|
||
experimental.well_formed_exports=true | ||
|
||
[strict] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
shell: test.sh | ||
skip_saved_state: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
Start server in classic mode | ||
|
||
Value cycle should include both files | ||
digraph { | ||
"fileB.js" -> "fileA.js" | ||
"fileA.js" -> "fileB.js" | ||
} | ||
Type cycle should include both files | ||
digraph { | ||
"fileB.js" -> "fileA.js" | ||
"fileA.js" -> "fileB.js" | ||
} | ||
Start server in types-first mode | ||
|
||
Value cycle should include both files | ||
digraph { | ||
"fileB.js" -> "fileA.js" | ||
"fileA.js" -> "fileB.js" | ||
} | ||
Type cycle should be empty | ||
digraph { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// @flow | ||
|
||
const B = require('./fileB'); | ||
|
||
class A {} | ||
|
||
module.exports = A; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// @flow | ||
|
||
const A = require("./fileA"); | ||
|
||
class B extends A {} | ||
|
||
module.exports = B; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
assert_ok "$FLOW" stop | ||
|
||
printf "\\nStart server in classic mode\\n" | ||
start_flow . | ||
|
||
printf "\\nValue cycle should include both files\\n" | ||
assert_ok "$FLOW" cycle --strip-root fileA.js | ||
|
||
printf "\\nType cycle should include both files\\n" | ||
assert_ok "$FLOW" cycle --strip-root --types fileA.js | ||
|
||
assert_ok "$FLOW" stop | ||
|
||
printf "\\nStart server in types-first mode\\n" | ||
start_flow . --types-first | ||
|
||
printf "\\nValue cycle should include both files\\n" | ||
assert_ok "$FLOW" cycle --strip-root fileA.js | ||
|
||
printf "\\nType cycle should be empty\\n" | ||
assert_ok "$FLOW" cycle --strip-root --types fileA.js | ||
|
||
assert_ok "$FLOW" stop | ||
|
||
printf "\\n" |