Created
June 6, 2016 14:40
-
-
Save jonvuri/90400fe4394f4064ec725ae0aec4f75c to your computer and use it in GitHub Desktop.
Sealed object experiments with Flow
This file contains hidden or 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
type Foo = { | |
prop: boolean, | |
prop2: boolean | |
}; | |
type Bar = { | |
prop: boolean, | |
prop2: boolean, | |
[key: string]: void | |
} | |
// No error - why not? | |
var f: Foo = { | |
prop: true, | |
prop2: false, | |
otherProp: 3 | |
} | |
// Does give an error for 'otherProp' as expected | |
var b: Bar = { | |
prop: true, | |
prop2: false, | |
otherProp: 3 | |
} | |
// No error as expected | |
f.prop = false; | |
// Does give an error - why? | |
b.prop = false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment