title: TypeScript: What does {[key: string]: any} means as return type of a function?
body: <p>I'm currently learning TypeScript and Angular. While reading about Custom validators I came across the following piece of code from <a href="https://angular.io/guide/form-validation" rel="nofollow noreferrer">https://angular.io/guide/form-validation</a>.</p>
  
  <pre><code>export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
    return (control: AbstractControl): {[key: string]: any} | null =&gt; {
      const forbidden = nameRe.test(control.value);
      return forbidden ? {'forbiddenName': {value: control.value}} : null;
    };
  }
  </code></pre>
  
  <p>I don't really understand what return type of the inner function ie <code>{[key: string]: any}</code> means? I understand <code>key:string</code> part, ie Object's key is of type string but what exactly <code>{[key: string]: any}</code>  means?</p>