I might be missing something here, but I don't understand why the following code isn't valid:
interface TestType {
id: string;
}
interface TestConstraint<T extends TestType> {
readonly id: string;
readonly rawData: Partial<T>
}
class GenericClass<T extends TestType> implements TestConstraint<T> {
readonly id: string;
constructor(
rawData: T
) {
this.id = rawData.id;
}
get rawData(): Partial<T> {
return {
id: this.id,
};
// return {
// id: this.id,
// } as Partial<T>;
}
}
The compiler is returning an error:
Type '{ id: string; }' is not assignable to type 'Partial<T>'.(2322)
That seems weird because that's roughly the definition of the TestType.