title: How to properly type the input for String.prototype.replace?
body: <p>I need to keep an array of inputs to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace" rel="nofollow noreferrer"><code>String.prototype.replace</code></a>. When trying to define an interface to use as a type for this array according to the type of the function itself, TypeScript is rejecting with a TS2769 error.</p>
  <p>Code:</p>
  <pre class="lang-ts prettyprint-override"><code>interface Replacment {
    searchValue: RegExp;
    replacer: string | ((substring: string, ...args: any[]) =&gt; string);
  }
  
  const r1 = {searchValue: /bc/, replacer: 'de'};
  const r2 = {searchValue: /bc/, replacer: () =&gt; 'de'};
  const r3: Replacment = {searchValue: /bc/, replacer: 'de'};
  const r4: Replacment = {searchValue: /bc/, replacer: () =&gt; 'de'}; // or (_substring: string, ..._args: any[]) =&gt; 'de'
  
  'abc'.replace(/bc/, 'de');
  'abc'.replace(/bc/, () =&gt; 'de');
  
  'abc'.replace(r1.searchValue, r1.replacer);
  'abc'.replace(r2.searchValue, r2.replacer);
  'abc'.replace(r3.searchValue, r3.replacer); // &lt;-- TS2769
  'abc'.replace(r4.searchValue, r4.replacer); // &lt;-- TS2769
  </code></pre>
  <p>Error:</p>
  <pre>
  (property) Replacment.replacer: string | ((substring: string, ...args: any[]) => string)
  No overload matches this call.
    The last overload gave the following error.
      Argument of type 'string | ((substring: string, ...args: any[]) => string)' is not assignable to parameter of type '(substring: string, ...args: any[]) => string'.
        Type 'string' is not assignable to type '(substring: string, ...args: any[]) => string'.(2769)
  </pre>
  <p>Any thoughts?</p>
  <hr />
  <p><code>replace</code> is defined as:</p>
  <pre class="lang-ts prettyprint-override"><code>replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
  replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) =&gt; string): string; }, replacer: (substring: string, ...args: any[]) =&gt; string): string;
  </code></pre>