flowtype

Can Flow limit strings to a number of alternatives, similar to enum?


In some legacy code, strings are used as enums, and should be limited to a certain number of available values. Is this possible to do with Flow?


Solution

  • Yes, it's called a "literal union" in flow. See https://flow.org/en/docs/types/literals/.