title: Typescript ensure correct class type
body: <p>I'm trying to strongly type my ID attributes in my classes, but look like typescript doesn't care.</p>
  <pre><code>static create(id: CustomerWalletID | ProviderWalletID, name: string, owner: CustomerID) {
      return new CustomerWallet(id, {
        name,
        owner,
      });
    }
  
    private constructor(id: CustomerWalletID, private props: Args) {
      super(id);
    }
  </code></pre>
  <p>As you can see the constructor expects <code>CustomerWalletID</code> and can receive <code>CustomerWalletID | ProviderWalletID</code> as args, which is supposed to trigger a compilation warning. It doesn't.</p>
  <p>Here are my ID classes :</p>
  <pre><code>export class CustomerWalletID extends ValueObject&lt;string&gt; {
    equals(customerWalletID: CustomerWalletID) {
      return customerWalletID.value === this.value;
    }
  }
  
  export class ProviderWalletID extends ValueObject&lt;string&gt; {
    equals(providerWalletID: ProviderWalletID) {
      return providerWalletID.value === this.value;
    }
  }
  
  export abstract class ValueObject&lt;T&gt; {
    protected readonly _value: T;
  
    constructor(props: T) {
      this._value = Object.freeze(props);
    }
  
    get value(): T {
      return this._value;
    }
  
    public abstract equals(_vo: ValueObject&lt;T&gt;): boolean;
  }
  </code></pre>
  <p>What am I doing wrongly?</p>
  <p>Thanks</p>