-
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] lift shadow properties to real properties
Summary: This reuses another piece of annotate exports to make valid type annotations when a field is cast but never initialized. Reviewed By: panagosg7 Differential Revision: D16114811 fbshipit-source-id: 8756e140bf826432c73c670e071bd34f927d2279
- Loading branch information
1 parent
84e6b0f
commit ff7f12b
Showing
14 changed files
with
174 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[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 @@ | ||
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 = {}; |
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,65 @@ | ||
> insert-type a.js 3 18 3 20 | ||
cat a.js | ||
// @flow | ||
|
||
module.exports = ({}: {}); | ||
> insert-type b.js 3 23 3 25 | ||
cat b.js | ||
// @flow | ||
|
||
module.exports = { f: ({}: {}) }; | ||
> insert-type c.js 3 18 3 20 | ||
cat c.js | ||
// @flow | ||
|
||
const obj = { f: ({}: {}) }; | ||
|
||
obj.f = { x: 1 }; | ||
obj.f = { x: "a" }; | ||
|
||
module.exports = obj; | ||
> insert-type d.js 3 13 3 16 | ||
cat d.js | ||
// @flow | ||
|
||
const obj: {f: {x: number}, g: {x: string}} = { }; | ||
|
||
obj.f = { x: 1 }; | ||
obj["g"] = { x: "a" }; | ||
|
||
module.exports = obj; | ||
> insert-type e.js 3 13 3 15 | ||
cat e.js | ||
// @flow | ||
|
||
const obj: {a: number} = {}; | ||
declare function foo(x: { a: number }): void; | ||
foo(obj); | ||
module.exports = obj; | ||
> insert-type f.js 3 13 3 15 | ||
cat f.js | ||
// @flow | ||
|
||
const obj: {f: number} = {}; | ||
(obj.f: number); | ||
module.exports = obj; | ||
> insert-type g.js 5 13 5 15 | ||
cat g.js | ||
// @flow | ||
|
||
declare function foo<X: { a: 1 }>(x: X): void; | ||
|
||
const obj: {a: 1} = {}; | ||
foo(obj); | ||
module.exports = obj; | ||
> insert-type h.js 4 5 4 8 | ||
cat h.js | ||
// @flow | ||
|
||
|
||
let obj: {x: number} = {}; | ||
obj.x = 5; | ||
|
||
module.exports = obj; | ||
> 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 | ||
|
||
module.exports = { f: {} }; |
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 | ||
|
||
const obj = { f: {} }; | ||
|
||
obj.f = { x: 1 }; | ||
obj.f = { x: "a" }; | ||
|
||
module.exports = obj; |
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 | ||
|
||
const obj = { }; | ||
|
||
obj.f = { x: 1 }; | ||
obj["g"] = { x: "a" }; | ||
|
||
module.exports = obj; |
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 obj = {}; | ||
declare function foo(x: { a: number }): void; | ||
foo(obj); | ||
module.exports = obj; |
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 obj = {}; | ||
(obj.f: number); | ||
module.exports = obj; |
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 | ||
|
||
declare function foo<X: { a: 1 }>(x: X): void; | ||
|
||
const obj = {}; | ||
foo(obj); | ||
module.exports = obj; |
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 | ||
|
||
|
||
let obj = {}; | ||
obj.x = 5; | ||
|
||
module.exports = obj; |
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,22 @@ | ||
#!/bin/bash | ||
|
||
update_in_place(){ | ||
local FILE=$1; | ||
echo "> insert-type" "$@" | ||
assert_ok "$FLOW" autofix insert-type --in-place "$@" | ||
assert_ok "$FLOW" force-recheck "$FILE" | ||
echo "cat $FILE" | ||
cat "$FILE" | ||
} | ||
|
||
update_in_place a.js 3 18 3 20 | ||
update_in_place b.js 3 23 3 25 | ||
update_in_place c.js 3 18 3 20 | ||
update_in_place d.js 3 13 3 16 | ||
update_in_place e.js 3 13 3 15 | ||
update_in_place f.js 3 13 3 15 | ||
update_in_place g.js 5 13 5 15 | ||
update_in_place h.js 4 5 4 8 | ||
|
||
echo "> flow status" | ||
assert_ok "$FLOW" status --strip-root |