title: Return corresponded input type by name as string (string template literal)
body: <pre><code>type GenerateArrayKeyType&lt;T extends string, K extends number&gt; = `${T}.${K}`;
  
  type PathImpl&lt;T, Key extends keyof T&gt; =
    Key extends string
    ? T[Key] extends readonly unknown[] ?
      GenerateArrayKeyType&lt;Key, 0 | 1&gt;
      : T[Key] extends Record&lt;string, any&gt;
        ? | `${Key}.${PathImpl&lt;T[Key], Exclude&lt;keyof T[Key], keyof any[]&gt;&gt; &amp; string}`
          | `${Key}.${Exclude&lt;keyof T[Key], keyof any[]&gt; &amp; string}`
        : never
    : never;
  
  type PathImpl2&lt;T&gt; = PathImpl&lt;T, keyof T&gt; | keyof T;
  
  type Path&lt;T&gt; = PathImpl2&lt;T&gt; extends string | keyof T ? PathImpl2&lt;T&gt; : keyof T;
  
  type PathValue&lt;T, P extends Path&lt;T&gt;&gt; =
    P extends `${infer Key}.${infer Rest}`
    ? Key extends keyof T
      ? Rest extends Path&lt;T[Key]&gt;
        ? PathValue&lt;T[Key], Rest&gt;
        : T[Key] extends (infer U)[] 
          ? U
          : never
      : never
    : P extends keyof T
      ? T[P]
      : never;
  
  type DeepNest = {
    test: string[],
  }
  
  type Data = {
    array: string[],
    test: string,
    last: string,
    file: File[],
    date: Date[],
    nest: {
      test: string,
    },
    deep: {
      array: DeepNest[]
    }
  }
  
  type Pathes = Path&lt;Data&gt;;
  
  
  function test&lt;T, B extends Path&lt;T&gt; = Path&lt;T&gt;&gt;(name: B): PathValue&lt;T, B&gt; {
      return '' as any;
  }
  
  
  const output = test&lt;Data&gt;('test')
  </code></pre>
  <p>I would like to extract type from a string. The above code works with the name look-up <code>test</code>, however, the return type will return all types instead of the targeted input type. any suggestions and ideas are appreciated.</p>
  <p><a href="https://www.typescriptlang.org/play?ts=4.2.0-dev.20201230#code/C4TwDgpgBA4hB2EBOBDYECCTUgNIRABVwIAeQqCAD3XgBMBnKB4JAS3gHMAaKXSmgkZR4AVwC2AI2QA%20KAF4oAAwAkAb0IBfAHTrcmpQG4AUMdCQoABTQALAJLiwAG3K98IAbWEBrAgHsAMyhCOXljKD4CTyEmFnYucKgAfmCAbXcAXWj6JiQIFDo-eCcPUXhveD8Ad3hUrKTEiLhEVHQsHHdiSFJ3XgAGKAAfKABGGUaoAC40zOzhACUIAGM-JDpSOI4eKBR4EHGIw%20Sh5T0CHXVrYHtHF0J0ggzeAFEqJadROjJfEECZx94Pz%20uxAdRkcgAZMxWFsDBMjsNVGp3Bc1K93p9vv4gvdMoDsTs9mCoFDNlw4UcItNEAA3ZCJakQOlIExmEhWWwOZwAJnIoQ51y5d3xvxxcmGQJxrPM0CuNj5CgFNx5CuoXliMK4J0lwWOcqFvJCUygOsI0vZcoAaigPmRCLxLHMmHK%20aFEo61TFTmoOAFkJEQKjff7FiwKcd3E6TQTCBMUqHgFGXbjHgdKSkrTbRHaHiAnlAE2mjtMU3mowAKYNIKAAVQAlHUoPDDika82qSImfTi53mQyrFHTXG0pYMhNGczzRYACIQCBgAByEBYirUiXQLGmZM4dW4xk0phlUGnaBQq8SKGwKBAW81O6e6%20XwFv8R4iScKE30Nfe4iATYTgQNMABiAEQLuiR0GgQHHtBEERIgX5rkcG7Pt%20Wy-lAmiYV887TMhhyXjg0yzvOS4sHUiQHgebIWHKy6Ki6J7ACgMissYARlEswBsEUUCoa4UAAEJJrYCqKMm4LlvAKDiDBQl1tMma2oJQlyARER5MAohIPAUAAOT6TsTAgiYNHGCs8Arn4ojAGAtmKgJzGseW%20mofpdZAA" rel="nofollow noreferrer">Playground</a></p>