title: How to determine if string is keyof interface in Typescript?
body: <p>I am trying to transform a CSS string into a <code>React.CSSProperties</code> object, but am getting a typing error with a Typescript upgrade to 3.5.3.</p>
  
  <p>TLDR; how to map strings to properties allowed by an interface</p>
  
  <pre><code>export function styleStringToCSSProperties(style: string | null) {
     const out: React.CSSProperties = {};
  
     if (!style) return null;
  
     const properties = style.split(';');
     if (!properties.length) return null;
  
     for (const property of properties) {
         const [key, value] = property.split(':');
  
         // Error here because I'm assuming the type checker sees the 
         // 'string' type output of 'camelCase' and because any string
         // is not limited to the exact possibilities in the error msg
         // below.  I was thinking of checking if the value of the output
         // of 'camelCase' is one of the allowed interface keys, but I 
         // can't find a way to do that
  
  
        // `Type 'string' is not assignable to type '"-moz-initial" | 
        // "inherit" | "initial" | "revert" | "unset" | undefined'`
  
         out[camelCase(key) as keyof React.CSSProperties] = value;
  
         // ^^^^ Brorked
    }
  
   return out;
  }
  </code></pre>