title: Creating a Lookup Object with Template Literal Types
body: <p>I've got a type defined as:</p>
  <pre class="lang-js prettyprint-override"><code>type Response = 'n_a' | 'n_o' | 'yes' | 'no'
  </code></pre>
  <p>I'd like to have a type that enforces that underscores are replaced with slashes:</p>
  <pre class="lang-js prettyprint-override"><code>type ReplaceUnderscoreWithSlash&lt;T extends string&gt; = 
       T extends `${infer Head}_${infer Tail}` ? `${Head}/${Tail}` : T;
  </code></pre>
  <p>Everything works as expected here:</p>
  <pre class="lang-js prettyprint-override"><code>type HumanReadableResponses = ReplaceUnderscoreWithSlash&lt;Response&gt;;
  </code></pre>
  <p>Now, I'd like to create a lookup object that I can use at runtime to convert from the underscore versions to the &quot;human readable&quot; versions but I'd like for the association to be typesafe.</p>
  <p>I tried writing this as</p>
  <pre class="lang-js prettyprint-override"><code>type LookupObject&lt;T extends string&gt; = Record&lt;T, ReplaceUnderscoreWithSlash&lt;T&gt;&gt;;
  </code></pre>
  <p>However, this doesn't provide key -&gt; value type safety like I was hoping to achieve since this appears to be valid:</p>
  <pre class="lang-js prettyprint-override"><code>const lookupObject: LookupObject&lt;Response&gt; = {
    n_a: 'n/a',
    n_o: 'n/a', // &lt;---- I'd like it if this threw an error because the only valid value should be 'n/o'
    no: 'no',
    yes: 'yes',
  };
  
  </code></pre>
  <p>Is what I'm trying to accomplish here possible?</p>