Flowtype - string incompatible with string enum : <p>I have a value that comes from a select input and is of type string, however I want to pass it into a function (<em>updateLanguage</em>) that receives as argument a string enum with a type alias (<em>Language</em>). </p>

<p>The problem I'm facing is that Flow only allows me to call <em>updateLanguage</em> if I explicitly compare my string value with the enum strings and I want to use an array function like array.includes.</p>

<p>This is a code simplification of my problem:</p>

<pre><code>// @flow

type SelectOption = {
    value: string
};
const selectedOption: SelectOption = {value: 'en'};

type Language = 'en' | 'pt' | 'es';
const availableLanguages: Language[] = ['en', 'pt'];

function updateLanguage(lang: Language) {
    // do nothing
}

// OK
if(selectedOption.value === 'en' || selectedOption.value === 'pt') {
  updateLanguage(selectedOption.value);
}

// FLOWTYPE ERRORS
if(availableLanguages.includes(selectedOption.value)) {
  updateLanguage(selectedOption.value);
}
</code></pre>

<p>running flow v0.30.0 gives the following output:</p>

<pre><code>example.js:21
 21: if(availableLanguages.includes(selectedOption.value)) {
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call of method `includes`
 21: if(availableLanguages.includes(selectedOption.value)) {
                                    ^^^^^^^^^^^^^^^^^^^^ string. This type is incompatible with
  9: const availableLanguages: Language[] = ['en', 'pt'];
                               ^^^^^^^^ string enum

example.js:22
 22:   updateLanguage(selectedOption.value);
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function call
 22:   updateLanguage(selectedOption.value);
                      ^^^^^^^^^^^^^^^^^^^^ string. This type is incompatible with
 11: function updateLanguage(lang: Language) {
                                   ^^^^^^^^ string enum


Found 2 errors
</code></pre>

<p>How can I check that the string value is part of the enum in a scalable manner?</p>
