title: Typescript: Create object with same keys but different values
body: <p>I have the following initial object</p>
  
  <pre><code>const initialValues = { name: 'Jon', email: 'jon@me.com' }
  </code></pre>
  
  <p>I would like to create an identical object except where all the values are <code>boolean</code> and default to <code>false</code>. Like so</p>
  
  <pre><code>const expected = { name: false, email: false }
  </code></pre>
  
  <p>I created the following function which does what I want</p>
  
  <pre><code>const expected = cloneWithDefaults&lt;typeof initialValues&gt;(initialValues)
  
  function cloneWithDefaults&lt;T&gt;(values: T) {
    type U = { [K in keyof T]: boolean }
    const keys = Object.keys(values) as Array&lt;keyof T&gt;
    const partial: Partial&lt;U&gt; = keys.reduce&lt;Partial&lt;U&gt;&gt;((acc, cur) =&gt; {
      acc[cur] = false
      return acc
    }, {})
    const final = partial as U
    return final
  }
  </code></pre>
  
  <p>I also created a second version which does not use reduce</p>
  
  <pre><code>function createCloneWithDefaultsV2&lt;T extends { [key: string]: unknown }&gt;(values: T) {
    type U = { [K in keyof T]: boolean }
    const keys = Object.keys(values) as Array&lt;keyof U&gt;
    const partial: Partial&lt;U&gt; = {}
    for (let k in keys) {
      partial[k] = false
    }
    const final = partial as U
    return final
  }
  </code></pre>
  
  <p>I wonder if there is a better / more succinct way of doing this. In particular I would like to get rid of the two uses of <code>as</code> if possible. </p>
  
  <p>In the v2 I wonder if there is any preference for <code>unknown</code> as opposed to <code>any</code>.</p>