Last active
April 19, 2019 00:23
-
-
Save Bannerets/5cf5315595478d308266bc7ff67ae7aa to your computer and use it in GitHub Desktop.
Computed object properties 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
/* | |
https://flow.org/try/#0FAFwngDgpgBA8jAvDA3jA2gcgIaYLoBcMAziAE4CWAdgOYwC+MAZKhpgEb5FUCuAtuyhkGMAPSiYAewDWMABQADLADpVXGKuUKYFYjGxUdVACZQAHkICUwYKYDGAG2xlYAN2dSicANw3vcyWVsbn5BMksxCSEySWE5c2g7EChja39A4JJyahoI8SlpPwDldhCBK0iC4HSSolJKWjyoshi4hKgklMsgA | |
*/ | |
type O = { ['a']: string } & { ['b']: number } // ok (`['...']: ...` is an indexer) | |
declare var o: O; | |
;(o.a: number) // error (expected) | |
;(o.a: string) // ok | |
;(o.b: number) // ok | |
;(o.b: string) // error (expected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment