Created
September 19, 2016 17:28
-
-
Save syrnick/f17c1d98d7b7f998b0f82adf4dc1818c to your computer and use it in GitHub Desktop.
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 | |
declare function SomeFn(): void; | |
type A = { | |
type: 'simple'; | |
foo: number; | |
requiredName: string; | |
}; | |
type B = { | |
type: 'error'; | |
bar: number; | |
errorHandler: SomeFn; | |
}; | |
type AorB = A | B; | |
class MyClass { | |
_states: {[key: string]: AorB}; | |
constructor() { | |
this._states = {}; | |
} | |
addB(n: string): void { | |
this._states[n] = { | |
type: 'error', | |
foo: 1, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fwiw this catches the mistake, not sure what's going on in your example :/