title: Yup .when validation with typescript
body: <p>I'm converting a validation schema from <code>jsx</code> to a <code>tsx</code> filetype. It works perfectly in <code>jsx</code> but in <code>tsx</code> I can't get the type for the yup <code>when</code> condition to pass. Even <code>any</code> fails to pass. Any idea how to type this correctly?
  The error appearing is</p>
  <p><code>Argument of type '(startTime: Date) =&gt; Yup.DateSchema&lt;Date | undefined, Record&lt;string, any&gt;, Date | undefined&gt; | undefined' is not assignable to parameter of type 'ConditionOptions&lt;RequiredDateSchema&lt;Date | undefined, Record&lt;string, any&gt;&gt;&gt;'.</code></p>
  <p><code>Type '(startTime: Date) =&gt; Yup.DateSchema&lt;Date | undefined, Record&lt;string, any&gt;, Date | undefined&gt; | undefined' is not assignable to type 'ConditionBuilder&lt;RequiredDateSchema&lt;Date | undefined, Record&lt;string, any&gt;&gt;&gt;'.</code></p>
  <p><code>Type 'DateSchema&lt;Date | undefined, Record&lt;string, any&gt;, Date | undefined&gt; | undefined' is not assignable to type 'SchemaLike'. Type 'undefined' is not assignable to type 'SchemaLike'.  TS2345</code></p>
  <p>My validation:</p>
  <pre><code>Yup.date().required('This field is required')
              .when('startTime', (startTime: Date) =&gt; { // &lt;-- this is where error appears
                  if (startTime) {
                      return Yup.date()
                          .min(startTime, 'End must be after Start')
                          .typeError('End is required')
                  }
              }),
  </code></pre>