title: How to infer correct type in <select> element?
body: <p>I have a Material select UI element:</p>
  <pre><code>&lt;Select
    labelId=&quot;demo-simple-select-label&quot;
    id=&quot;demo-simple-select&quot;
    value={sortType}
    onChange={handleChange}
  &gt;
    &lt;MenuItem value={'release_date'}&gt;Release date&lt;/MenuItem&gt;
    &lt;MenuItem value={'title'}&gt;Title&lt;/MenuItem&gt;
    {/* &lt;MenuItem value={'Date added'}&gt;Date added&lt;/MenuItem&gt; */}
  &lt;/Select&gt;
  </code></pre>
  <p>As you can see the value is a string <code>release_date</code> or <code>title</code>. I want to sort a array based on what option has been selected:</p>
  <pre><code>type IMovie = {
    title: string;
    poster_path: string;
    release_date: string;
    id: number;
    type?: any;
  };
  
  const handleChange = event =&gt; {
    setSortType(event.target.value);
    const type = event.target.value;
  
    localforage.getItem&lt;IMovie []&gt;('trackedMovies').then((value) =&gt; {
      let trackedMovies = value;
      trackedMovies = orderBy(trackedMovies, [movie =&gt; movie.type], ['asc']);
    })    
  };
  </code></pre>
  <p>This doesn't work, I think it's because the <code>trackedMovies = orderBy(trackedMovies, [movie =&gt; movie.type], ['asc']);</code> is of type <code>any</code>.</p>
  <p>If I replace the type with a <code>IMovie</code> property like <code>title</code> or <code>release_date</code> the <code>sortBy</code> does work:</p>
  <pre><code> trackedMovies = orderBy(trackedMovies, [movie =&gt; movie.type], ['asc']);
  </code></pre>
  <p>If I change the value in the <code>MenuItem</code>: <code>&lt;MenuItem value={release_date}&gt;Release date&lt;/MenuItem&gt;</code> I get a error that:</p>
  <blockquote>
  <p>Cannot find name 'release_date'.</p>
  </blockquote>
  <p>Which makes sense because there's no reference to <code>{release_date}</code>. I could solve this by using a switch but it would be much easier/better (I think) to use the direct value of the <code>MenuItem</code> to decide what the <code>sortBy</code> method should do.</p>