title: Typescript: Make Generic Typed Parameter Flow From Function to Function
body: <p>Consider the following code ( also on <a href="https://www.typescriptlang.org/play/?ssl=9&amp;ssc=1&amp;pln=10&amp;pc=1#code/JYOwLgpgTgZghgYwgAgApQPYAcDOAeASUgFsA+ZAbwChlbkcIAbCBSAEyImIH4AuZTsSoBfKlRgBXEK2AYQyYnADWEAEoQwEqCAAUWTLn7psOAJSUadYDGR6DOAHQNmrCBxLnqdb8igat8vomTkws7IKWtKKRvv7ayADkCSJiktJgsvISDIQkpDox2dDGhmj2uVzkALyUop4xCHI4YLFgAGpwjMg1iirqmto6RVAlZgDcMX4D8lMdjBPRoJCwiCgAsgCeghbeCMBgG-wJzVCgAOYJADSTcBkgZ-wgEsQARtApVI0gzfShru5cbrIIp4TaCfKmKhAA" rel="nofollow noreferrer">TS Play</a> )</p>
  
  <pre class="lang-js prettyprint-override"><code>
  interface Props&lt;Item&gt; {
      selectedItem?: Item
  }
  
  function makeReturn(props: Props) { // complaints : Generic type 'Props&lt;Item&gt;' requires 1 type argument(s).
      if (props.selectedItem) {
          return props.selectedItem
      }
  
      return ''
  }
  
  function useAutosuggest&lt;Item&gt;(
      userProps: Props&lt;Item&gt; = {}
  ) {
      const retVal = makeReturn(userProps);
      return retVal;
  }
  
  interface MyItem {
      city: 'string',
      rating: number
  }
  
  const selectedItem = useAutosuggest&lt;MyItem&gt;()
  
  </code></pre>
  
  <p>My thought process is – what do I do, so that the <code>makeReturn</code> function be able to know that <code>selectedItem</code> should be of whatever type <code>useAutosuggest</code> takes in (in this case <code>MyType</code>). I'm not sure if I'm thinking correctly. If I am, what to do to act upon this thought process, if not what am I thinking wrong?</p>