title: Typescript - change value of a dictionary with a key variable
body: <p>I have an object:</p>
  <pre><code>const sampleExpenseData = {
    Time: &quot;11-12-19&quot;,
    Meals: 5130,
    Pantry: 10,
    Living: 10,
    Others: 0,
    Total: 74
  }
  </code></pre>
  <p>I would like to define a function such that it will update the value of a specific key, what I have so far is:</p>
  <pre><code>const updateValueInDict = (
    obj: typeof sampleExpenseData,
    key: keyof typeof sampleExpenseData,
    upDatedValue: string | number
  ): void =&gt; {
    obj[key] = upDatedValue  // this line throws error
  }
  </code></pre>
  <p>The error says:</p>
  <blockquote>
  <p>Type 'string | number' is not assignable to type 'never'.</p>
  <p>Type 'string' is not assignable to type 'never'.ts(2322)</p>
  </blockquote>
  <p>TIA!!!</p>