title: How to explicitly pass type arguments to generic functions in flow?
body: <p>I'm trying to explicitly specify the type when calling a generic function.</p>
  
  <p>For example:</p>
  
  <pre><code>export function gen&lt;T&gt;(a: string): { eat: T =&gt; string } {
    return {
      eat: (v: T): string =&gt; a
    };
  }
  </code></pre>
  
  <p>Of course, using C++-like syntax doesn't work, because flow extends Javascript syntax, and this is already a valid JS expression (a comparison):</p>
  
  <pre><code>const { eat } = gen&lt;number&gt;("str")
  </code></pre>
  
  <p><strong>What is the correct syntax?</strong></p>
  
  <p>I want to pass a type explicitly, because otherwise this sort of code won't produce an error:</p>
  
  <pre><code>const { eat } = gen("str")
  const a = eat(5)
  // I want this to be an error, but it is not
  const b = eat("foo")
  </code></pre>
  
  <p>I can of course annotate the assignment, causing the desired generic type to be inferred, but that can be cumbersome. <a href="https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVxhgLJwCYCuMApmAILrEAeADnAE4AuYUBAdgMaMCWcbYAc2JsAPABUAfAAoAhgC4wAZ0b1ubAQEoFAbzDEZjBWLABeCUpVqBYAL5htqMGHrFGBevwdOn+w2CkAbkZaFqrqpuYyjrYA3Kg26Jg4+ESkAEKJWAAicMSKbADkzAgMANZgAEbEHDIEiqTcjAWKYDJgHHAAtjQyqop8GFgdbMr2ega2poLCImwEnVX00gBEyvTLGujDo7q+kybTbFKrKhuovlIArJtJAJJgCDJszIwAFtwtjHCVpE969PQGAAaSoEZiNMAfMBsOCMc4GY5QOBwM6DVpsGGMAxWMBvX6KRTcARsTrCZg1fhVdrzRb9Un+J54SEtTFgOgE7gVEgPRqvOBg9GtDnE0nPTbbZi7AwKUkTGw6cZ+OYLYj0CKhHF2A5CI7LCq9VGyxhSAAMVDw+jwNywABIAKK0aqMO0Ahhoo3HL4ozZAA" rel="nofollow noreferrer">Try it here</a></p>