-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Spreading numbers, strings, and bools all result in `{||}`. We can model that instead of saying that those aren't objects, which helps out RN with some of the patterns they like to use. For example: ``` const styles = {...(showBlue() && {backgroundColor: 'blue'}), color: 'red'}; ``` should pass type checking and is a very interesting + reasonable pattern! object_kit handles a number of other object operations that are not spread, but I haven't verified that we have the correct behavior when we use this new rule in those operations. Until I verify those codepaths, I'm only turning this on for spreads. Reviewed By: gabelevi Differential Revision: D18270818 fbshipit-source-id: a4d1f4595cc9adaf8a81393f254d46457e3df1b3
- Loading branch information
1 parent
59f8d23
commit 5c09b8a
Showing
6 changed files
with
41 additions
and
6 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
type O1 = {..."foo"}; // error | ||
("foo": O1); | ||
type O1 = {..."foo"}; // No error | ||
("foo": O1); // Error |
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 @@ | ||
Found 0 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,14 @@ | ||
//@flow | ||
const a: {||} = {...3}; | ||
const b: {||} = {...(3: 3)}; | ||
const c: {||} = {...''}; | ||
const d: {||} = {...('': '')}; | ||
const e: {||} = {...false}; | ||
const f: {||} = {...(false: false)}; | ||
const g: {||} = {...null}; | ||
const h: {||} = {...(null: null)}; | ||
const i: {||} = {...undefined}; | ||
const j: {||} = {...(undefined: void)}; | ||
declare function showBlue(): boolean; | ||
const styles = {...(showBlue() && {backgroundColor: 'blue'}), color: 'red'}; |