title: How to convert unknown type to string in TypeScript?
body: <p>I'm dealing with an interface from an external piece of code. Boiled down to the minimum it looks like this:</p>
  <pre><code>interface Input {
      details?: unknown;
  }
  </code></pre>
  <p>Now I need to map this object into different object with type:</p>
  <pre><code>interface Output {
      message?: string;
  }
  </code></pre>
  <p>So <code>unknown</code> must be cast to a <code>string</code>. My initial approach was simply calling <code>input.details.toString()</code>, but <code>toString</code> is not available because <code>unknown</code> can also be <code>null</code> or <code>undefined</code>.</p>
  <p>How do I transform <code>Input</code> to <code>Output</code>?</p>