Created
January 8, 2019 22:21
-
-
Save markbrown4/c9b8155038b40f45738aa0484cca01df to your computer and use it in GitHub Desktop.
Read / write access in Flow
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
// @flow | |
// read / write access | |
type ReadWriteType = { | |
+readOnly: number | string, | |
-writeOnly: string | |
}; | |
function test(obj: ReadWriteType) { | |
const read = obj.readOnly; | |
obj.writeOnly = "Written"; | |
obj.readOnly = "Not Written"; // readOnly is not writeable | |
const notRead = obj.writeOnly; // No Error | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment