Flow: Infer string enum from the result of string concatenation

Created on 2 Apr 2017  路  1Comment  路  Source: facebook/flow

Currently flow cannot infer that the result of string concatenation is a string enum value:

type command = 'go_in' | 'go_out'

const com1: command = 'go_in' // OK
const com2: command = 'go_' + 'in' // Error
const createCommand = (dir: 'in' | 'out'): command => `go_${dir}` // Error

Demo

Most helpful comment

I'd say that while something like this is possible, it's out of scope of Flow.

>All comments

I'd say that while something like this is possible, it's out of scope of Flow.

Was this page helpful?
0 / 5 - 0 ratings