title: Type 'string[]' is not assignable to type '("toString" | "valueOf")[]'
body: <p>I have two properties on an object being passed into a function. I want to constrain the <code>deps</code> property on one object's properties to be a <em>key</em> of the other object.</p>
  <p>E.g.:</p>
  <pre><code>const config = {
    modules: {
      bar: {
        baz: true,
        deps: ['foo', 'notADep'],
        factory: () =&gt; Promise.resolve(() =&gt; {}),
      },
    },
    services: {
      foo: { factory: () =&gt; Promise.resolve(() =&gt; {}) },
    },
  };
  </code></pre>
  <p>In the above config, <code>foo</code> is valid, but <code>notADep</code> is not valid.</p>
  <p>Here's my code:</p>
  <pre><code>function createApp&lt;T extends Config&gt;(config: T) {}
  
  export type Service&lt;T&gt; = {
    factory: () =&gt; Promise&lt;() =&gt; void&gt;;
    deps?: (keyof T &amp; string)[] | undefined;
  }
  
  export type Services&lt;T = any&gt; = Partial&lt;Record&lt;keyof T, Service&lt;any&gt;&gt;&gt;;
  
  export type Modules&lt;T = any&gt; = Record&lt;string, {
    baz: boolean,
  } &amp; Service&lt;keyof T&gt;&gt;
  
  interface Config {
    modules: Modules;
    services: Services;
  }
  </code></pre>
  <p>I'm getting an error on the <code>config</code> parameter that</p>
  <pre><code>Argument of type '{ modules: { bar: { baz: boolean; deps: string[]; factory: () =&gt; Promise&lt;() =&gt; void&gt;; }; }; services: { foo: { factory: () =&gt; Promise&lt;() =&gt; void&gt;; }; }; }' is not assignable to parameter of type 'Config'.
    Types of property 'modules' are incompatible.
      Type '{ bar: { baz: boolean; deps: string[]; factory: () =&gt; Promise&lt;() =&gt; void&gt;; }; }' is not assignable to type 'Modules&lt;any&gt;'.
        Property 'bar' is incompatible with index signature.
          Type '{ baz: boolean; deps: string[]; factory: () =&gt; Promise&lt;() =&gt; void&gt;; }' is not assignable to type '{ baz: boolean; } &amp; Service&lt;string | number | symbol&gt;'.
            Type '{ baz: boolean; deps: string[]; factory: () =&gt; Promise&lt;() =&gt; void&gt;; }' is not assignable to type 'Service&lt;string | number | symbol&gt;'.
              Types of property 'deps' are incompatible.
                Type 'string[]' is not assignable to type '(&quot;toString&quot; | &quot;valueOf&quot;)[]'.
                  Type 'string' is not assignable to type '&quot;toString&quot; | &quot;valueOf&quot;'.
  </code></pre>
  <p><a href="https://www.typescriptlang.org/play?ssl=32&amp;ssc=2&amp;pln=16&amp;pc=1#code/MYewdgzgLgBKYDMCWBzGBeGBvAsAKBhgFsQATAVwBsBTCALm30MICMBDAJwdwOdbYBeDKB3LUANEz4xS1AA70YAbQDkCECBXiYKsCCgBBACLyVAXUm8+CNsCggOATwYAKAJQYAfDAAKHEERIENQAdBy0IJQAbtQu7l7YAL5ulnyJqTDpUsEcUUjAtNxShOog3DA2dg7OMPHo3n4BQaHhEJExcR71SR5ZvH2JANz4+PDQMGxychhw4WxQ1AZTLvDIKG7DePgI5GB2SOCz1POLUwA8ACow1AAeC2CkEDAAwuBrnitvqAwXHliJIzwtzkDlgUEccmoMAAytRcvlqJdvJgeCVbPYnK4ug1-IFgmc6t4oiAkKRPJtCLIFAB+VwAa2ojhACBgVwAZDBoBwkGB1kozDAAD4wXayZBgaikTYArZAm4gjhgiFQ2HwgoQS4zNhgRzI3ycKBINiUM4AJWooA4pDODKZLIu2lVeQKZ21us85MBwNBMHBkJgAFkyFRaJrMG69ebLdauTyUNpUTB2EIkxoaNrLIkYBynQibYzmayPYCeQsOJUoa9EKhGLwSBQaIogw3aBTOXDnYUYR2ERBpUA" rel="nofollow noreferrer">Playground</a></p>