title: Use typescript to extract type of type guard
body: <p>I have the following function:</p>
  <pre><code>function isFish(pet: Fish | Bird): pet is Fish {
    return (pet as Fish).swim !== undefined;
  }
  </code></pre>
  <p>How can I extract the type <code>Fish</code> using <code>typeof isFish</code>?</p>
  <hr />
  <p>For example:</p>
  <pre><code>type ExtractedFishType = GuardType&lt;typeof isFish&gt;
  </code></pre>
  <hr />
  <pre><code>type GuardType&lt;T&gt; = ... 
  </code></pre>
  <p>But how can i implement <code>GuardType</code>?</p>
  <p>See this <a href="https://www.typescriptlang.org/play?#code/C4TwDgpgBAYglgZwBZQLxQN4Cgq6ggdzgFsAuKAIwHsqAbCAQwDssBfLLUSKAITgCcAJmkw48AM1ohy1Ooxbss4gK5MAxsDhUmURPGQAKSMHL6UAH14DBASnLHdCWIhTZc-CMGX8dRz1AYnMxsAOkISKABCVHRVQQhxOCYIQQBuNg4uaABRAA9gfgYNFIAVcAgARhEAJU9vJjLIAB4sqnFHMwA+KAB6HqgPLx8nWXpmTPKoPIKi4FLygCYRAHFlBiFGiBbyto6Xbr78JCplWmEIfMKNKAAiMxuAGkplYChBKggnJipXgip+ADWWCAA" rel="nofollow noreferrer">playground</a> for reference.</p>