Repository: TypeScript
Issue: Mixin / Inheritance problem with Typescript - string not assignable to string|number|symbol
Labels: Bug,Help Wanted

# Bug Report

I have a typescript class. I'd like to subclass it and add a mixin. However, it keeps telling me that string not assignable to string|number|symbol. I don't understand why because the method signatures are the same.

### 🔎 Search Terms

typescript mixin prototype

### 🕗 Version & Regression Information

4.9.5

I just started using Typescript, so 4.9.5 is the version I was using since I started seeing it.

### ⏯ Playground Link


[this shows the problem with UserRecord](https://www.typescriptlang.org/play?#code/C4TwDgpgBAKgsgewCYQDZQLxQN4CgoFQDkAqgM4QBORUAXDvoUwK4WUB2AhgLbT1nBKAS3YBzADSMmBMJzJkA7gkpI6UAcLEEAPlGbsUAMxEQkkpgF9zhIgEEACgEkA0hBA16eaYTDCAbpzAEK4g-IIiElJQFrgWANy4oJCw9pQIYGQAPDBQEAAeQQZkUADWbgiGsIgoqAB8mFD2nJTAQpyo2dVoANowALq1CYng0ADCCOwazADGwMrZDdgW9VjsEApQABQAdLvNomT0nOwg3X0AlJj1MENQ06hyxQBqEQBKENPKSAv5hUjFZRAFSqyDQ9S8hE+k0EMzmlE2UF8QgCQURaQy9BgqXSWRgtUu2GiuCiYGYACNUEJpuoIMBMs5cgUIEVSuVKlj0bjarVNgB9QH0ZwEmIxXCGfSzIQTKCvBCoCBwIR5EQ-Jks8bQyiw5Q8gBCcggmIJUUotOYHDuD3kMrlCqVIkZf2K+ooOAI8VixPujyg5Co70+KkdzP+NvliuV7E2LzEAa+mVIbCI+IYTFJFKpNLpDN+IYBbJSnITfuo3L5AqgQpwIqAA)

[this shows the way to work around the problem](https://www.typescriptlang.org/play?ts=4.9.5&ssl=28&ssc=12&pln=31&pc=11#code/C4TwDgpgBAKgsgewCYQDZQLxQN4CgoFQDkAqgM4QBORUAXDvoUwK4WUB2AhgLbT1nBKAS3YBzADSMmBMJzJkA7gkpI6UAcLEEAPlGbsUAMxEQkkpgF9zhIgEEACgEkA0hBA16eaYTDCAbpzAEK4g-IIiElJQFrgWANy4oJCw9pQIYGQAPDBQEAAeQQZkUADWbgiGsIgoqAB8mFD2nJTAQpyo2dVoANowALq1CbgiQZSGnADG0I4AwgjsGswTwJwARqgQ2Q3YFvVehOwQCgAUAHTnzaJk9JzsIACU9DAJMYng0ADqlJxg2fVYx3umHqzzeyRI7AU31+MH+sFyBQgRSgIkMVCgJCgAH4MQjCkhil8fplUeiAGr1HFktSHPzo+i0qgJJLQADKh04JRAfwaEKhxKJv0ZlHqADIoMccvl8cVSZQoAAlABM2KggsyyvqDIgdMo90GuFwE1QcmKZIiCogE2USC20qRBNK5Uq8GQaD2UWtC0ES2AymOviEASCUF86WuKTSGT+QOw0UNTDAzHWQgm6ggwEyzjxDuKZRAFUj4b+tWOAH18-RnOIoAFUMwIE9UsXYd1nH1YzFXoZ9MshPNFQgNnAhHkRHbEcjZvNFss1htSwAhOSN2Cxz0m+SD4ejkQ55HLig4eJRSgZ5gcbcQEdj9hQOQMbwEQ4KCXnU6XCO3B70BVD6+7uwCRPqGaR+iyNx3MBhAWFA4qgq8xqmhibCWtaKj7o6f47rexzmmIaE2pkpBsEQtTromyaoKm6aZtm9rIvmhYwM20YkVQZGlhWbhVjWdYNk2UZZOx1C1G2HbHrEuAvihVCESoxw7PcpwUMAxwAESsFQXC8OpNb6EYJhIPcCQAPSmSBlkAHpYkAA)

### 💻 Code

This is as short as I can make the example and still show what's happening:

```
type TModel = {
    'User' : {
        username : string,
        password : string  | undefined,
    },
    'APIKey' : {
        privateKey: string,
    }
};
type TProps<T extends keyof TModel> = Partial<TModel[T]>;

type Constructor<T = {}> = new (...args: any[]) => T;

 class VingRecord<T extends keyof TModel> {
    constructor( private props: TProps<T>) { }

    public set<K extends keyof TProps<T>>(_key: K) {}
}

function RoleMixin<T extends Constructor>(Base: T) {
    return class RoleMixin extends Base {  };
}

class UserRecord extends RoleMixin(VingRecord<'User'>) {
    public set<K extends keyof TProps<'User'>>(_key: K) {}
}
```

and if you replace the RoleMixin with this it hides the problem with the funky prototype:

```
function RoleMixin<T extends IConstructable>(Base: T) {
    class RoleMixin extends Base {};
    return RoleMixin as {
        new (...args: any): RoleMixin;
        prototype: any;
    } & T;
}
```

### 🙁 Actual behavior

The code works, but typescript has a problem with the mixin thinking the type on VingRecord is any rather than 'User'.  So it reports a type mismatch on the UserRecord.

[More detail here with the guys who spotted the behavior](https://discord.com/channels/508357248330760243/1077697113540018226)

### 🙂 Expected behavior

I should be able to do the inheritance as shown in the code sample above without having to do the funky return from the mixin.