-
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.
[autofix][insert-type] add passing annotate exports tests
Summary: This commit adds all the tests from annotate exports that can be performed with insert-type. Reviewed By: panagosg7 Differential Revision: D16035039 fbshipit-source-id: 016b5723c0f275148085d2c9ebc0e042767297e2
- Loading branch information
1 parent
de679c5
commit f796b60
Showing
98 changed files
with
1,114 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[lints] | ||
|
||
[options] | ||
experimental.types_first=true | ||
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 @@ | ||
shell: test.sh |
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,5 @@ | ||
// @flow | ||
|
||
declare var cond: boolean; | ||
|
||
module.exports = () => (cond ? true : false); |
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,8 @@ | ||
> cat a.js | ||
// @flow | ||
|
||
declare var cond: boolean; | ||
|
||
module.exports = (): boolean => (cond ? true : false); | ||
> flow status | ||
No errors! |
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,10 @@ | ||
#!/bin/bash | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place a.js 5 20 | ||
assert_ok "$FLOW" force-recheck a.js | ||
|
||
echo "> cat a.js" | ||
cat a.js | ||
|
||
echo "> flow status" | ||
assert_ok "$FLOW" status |
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.types_first=true | ||
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 @@ | ||
shell: test.sh |
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,8 @@ | ||
// @flow | ||
|
||
class C {} | ||
// XYZXYZ | ||
export default class { | ||
array = []; | ||
num = 1; | ||
} |
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,31 @@ | ||
> cat a.js | ||
// @flow | ||
|
||
class C {} | ||
// XYZXYZ | ||
export default class { | ||
array: Array<empty> = []; | ||
num: number = 1; | ||
} | ||
> cat b.js | ||
// @flow | ||
|
||
class C { | ||
m(): number { | ||
return 1; | ||
} | ||
} | ||
module.exports = C; | ||
> cat c.js | ||
// @flow | ||
|
||
class A { | ||
f: ((x: string) => string) = (x: string) => x; | ||
} | ||
|
||
module.exports = { | ||
a: A, | ||
b: (x: string): string => x, | ||
}; | ||
> flow status | ||
No errors! |
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,8 @@ | ||
// @flow | ||
|
||
class C { | ||
m() { | ||
return 1; | ||
} | ||
} | ||
module.exports = C; |
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,10 @@ | ||
// @flow | ||
|
||
class A { | ||
f = (x: string) => x; | ||
} | ||
|
||
module.exports = { | ||
a: A, | ||
b: (x: string) => x, | ||
}; |
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,19 @@ | ||
#!/bin/bash | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place a.js 6 3 6 14 | ||
assert_ok "$FLOW" autofix insert-type --in-place a.js 7 3 7 11 | ||
echo "> cat a.js" | ||
cat a.js | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place b.js 4 6 | ||
echo "> cat b.js" | ||
cat b.js | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place c.js 4 3 4 24 | ||
assert_ok "$FLOW" autofix insert-type --in-place c.js 9 17 | ||
echo "> cat c.js" | ||
cat c.js | ||
|
||
assert_ok "$FLOW" force-recheck {a,b,c}.js | ||
echo "> flow status" | ||
assert_ok "$FLOW" status |
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.types_first=true | ||
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 @@ | ||
shell: test.sh |
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,3 @@ | ||
// @flow | ||
|
||
module.exports = () => 1; |
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,3 @@ | ||
// @flow | ||
|
||
module.exports = () => 1; |
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,10 @@ | ||
> cat a.js | ||
// @flow | ||
|
||
module.exports = (): number => 1; | ||
> cat a.js.flow | ||
// @flow | ||
|
||
module.exports = (): number => 1; | ||
> flow status | ||
No errors! |
Empty file.
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 @@ | ||
#!/bin/bash | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place a.js 3 20 | ||
echo "> cat a.js" | ||
cat a.js | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place a.js.flow 3 20 | ||
echo "> cat a.js.flow" | ||
cat a.js.flow | ||
|
||
assert_ok "$FLOW" force-recheck a.js a.js.flow | ||
echo "> flow status" | ||
assert_ok "$FLOW" status |
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,16 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
lib | ||
|
||
[lints] | ||
|
||
[options] | ||
no_flowlib=false | ||
facebook.fbt=FbtElement | ||
experimental.well_formed_exports=true | ||
experimental.types_first=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 @@ | ||
shell: test.sh |
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,6 @@ | ||
// @flow | ||
|
||
const React = require("react"); | ||
|
||
const foo = () => <fbt />; | ||
module.exports = foo(); |
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,9 @@ | ||
> cat a.js | ||
// @flow | ||
|
||
const React = require("react"); | ||
|
||
const foo = () => <fbt />; | ||
module.exports = (foo(): FbtResultBase); | ||
> flow status | ||
No errors! |
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,3 @@ | ||
// @flow | ||
declare type FbtElement = FbtResultBase; | ||
declare class FbtResultBase {} |
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,9 @@ | ||
#!/bin/bash | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place a.js 6 18 6 23 | ||
assert_ok "$FLOW" force-recheck a.js | ||
|
||
echo "> cat a.js" | ||
cat a.js | ||
echo "> flow status" | ||
assert_ok "$FLOW" status |
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.types_first=true | ||
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 @@ | ||
shell: test.sh |
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,5 @@ | ||
// @flow | ||
|
||
export function f() { | ||
return 1; | ||
} |
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,14 @@ | ||
> cat a.js | ||
// @flow | ||
|
||
export function f(): number { | ||
return 1; | ||
} | ||
> cat b.js | ||
// @flow | ||
|
||
const functionArray = (): Array<(x: number) => number> => ([(x: number) => x]) | ||
|
||
module.exports = functionArray; | ||
> flow status | ||
No errors! |
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,5 @@ | ||
// @flow | ||
|
||
const functionArray = () => ([(x: number) => x]) | ||
|
||
module.exports = functionArray; |
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,14 @@ | ||
#!/bin/bash | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place a.js 3 20 | ||
assert_ok "$FLOW" force-recheck a.js | ||
echo "> cat a.js" | ||
cat a.js | ||
|
||
assert_ok "$FLOW" autofix insert-type --in-place b.js 3 25 | ||
assert_ok "$FLOW" force-recheck b.js | ||
echo "> cat b.js" | ||
cat b.js | ||
|
||
echo "> flow status" | ||
assert_ok "$FLOW" status |
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,14 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[lints] | ||
|
||
[options] | ||
no_flowlib=false | ||
experimental.types_first=true | ||
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 @@ | ||
shell: test.sh |
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,17 @@ | ||
// @flow | ||
|
||
const React = require('react'); | ||
|
||
declare var x1: { f: number } | any; | ||
declare var x2: any | { f: number }; | ||
declare var x3: any | { f: number } | { node: React.Node }; | ||
declare var x4: { f: number } | any | { node: React.Node }; | ||
declare var x5: { f: number } | { node: React.Node } | any; | ||
|
||
module.exports = [ | ||
() => x1, | ||
() => x2, | ||
() => x3, | ||
() => x4, | ||
() => x5, | ||
]; |
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,4 @@ | ||
// @flow | ||
|
||
declare var x1: { f: number } | any; | ||
module.exports = () => x1; |
4 changes: 4 additions & 0 deletions
4
tests/autofix-hard-coded-fixes/any-to-flowfixme-strict-local.js
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,4 @@ | ||
// @flow strict-local | ||
|
||
declare var x1: { f: number } | any; | ||
module.exports = () => x1; |
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,4 @@ | ||
// @flow strict | ||
|
||
declare var x1: { f: number } | any; | ||
module.exports = () => x1; |
Oops, something went wrong.