title: A partly partial with io-ts
body: <p>I'm having some issues with using <code>io-ts</code>. I've found that its really lacking documentation, most of the progress I've made is through GitHub issues. And no I don't understand the HKTs so no help there.</p>
  
  <p>Basically I'm creating a type elsewhere, <code>type</code> which has a certain set of keys:</p>
  
  <pre><code>import * as S from 'io-ts/lib/Schema'
  
  const someType = S.make(S =&gt; S.type({
    id: S.string,
    foo: S.string,
    bar: S.boolean
  }))
  
  type T = S.TypeOf&lt;typeof someType&gt;
  </code></pre>
  
  <p>And I need to transform this to a <em>partial</em> where some keys are still required. Say just the <code>id</code> key is still required, defining the type in TS would be like:</p>
  
  <pre><code>type PartlyPartial &lt;T&gt; = Partial&lt;T&gt; &amp; { id: string }
  </code></pre>
  
  <p>Simple!</p>
  
  <p>Now, I want to be able to do this at runtime through <code>io-ts</code> so that I can create a validator function with the <code>Guard</code> module. This is what I've got so far:</p>
  
  <pre><code>import * as G from 'io-ts/lib/Guard'
  
  const propsBase = S.make(S =&gt; S.type({
    id: S.string
  }))
  
  const partial = S.make(S =&gt; S.intersection(
    someType(S) // needs to be partial,
    propsBase(S)
  ))
  
  // So that this returns `true`
  partial(G.guard).is({
    id: 'some id',
    bar: true
  })
  </code></pre>
  
  <p>But the <code>someType(S)</code> defines the type as having all keys required, but none of them should be required.</p>
  
  <p>This is driving me mad, any help would be much appreciated!</p>