Skip to content

Instantly share code, notes, and snippets.

@markbrown4
Created January 8, 2019 22:21
Show Gist options
  • Save markbrown4/c9b8155038b40f45738aa0484cca01df to your computer and use it in GitHub Desktop.
Save markbrown4/c9b8155038b40f45738aa0484cca01df to your computer and use it in GitHub Desktop.
Read / write access in Flow
// @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