title: How to use Proxy<T> with a different type than T as argument?
body: <p>I'm in a situation where I want to use <code>Proxy</code>, to "load balance" between a list of class.</p>
  
  <p>A naive example of what I'm trying to do is the following :</p>
  
  <pre><code>class Foo {
      constructor(private msg: string) {}
  
      foo() {
          console.log(this.msg);
      }
  }
  
  // @ts-ignore
  const proxy: Foo = new Proxy([new Foo('foo'), new Foo('bar')], {
      get: (o, key) =&gt; {
          const client = o[Math.floor(Math.random() * o.length)];
          console.log(client, key);
          return client[key];
      },
  });
  proxy.foo();
  </code></pre>
  
  <p>This "works". The problem is that I'm using typescript. And, due to the <code>Proxy</code> type definition we can't do something like</p>
  
  <pre><code>new Proxy&lt;Foo&gt;([new Foo(), new Foo()], handler)
  </code></pre>
  
  <p>as it produce the following error :</p>
  
  <blockquote>
    <p>Argument of type 'Foo[]' is not assignable to parameter of type 'Foo'.</p>
  </blockquote>
  
  <p>Is there a way to achieve this ; without loosing type checking ?</p>