export class Attributes<T> {
constructor(private data: T) {}
get<K extends keyof T>(key: K): T[K] {
return this.data[key];
}
set(update: T): void {
Object.assign(this.data, update);
}
}
错误的屏幕截图 错误
和文字版本
No overload matches this call.
Overload 1 of 4, '(target: {}, source: T): {} & T', gave the following error.
Argument of type 'T' is not assignable to parameter of type '{}'.
Overload 2 of 4, '(target: object, ...sources: any[]): any', gave the following error.
Argument of type 'T' is not assignable to parameter of type 'object'.ts(2769)
Attributes.ts(1, 25): This type parameter might need an `extends {}` constraint.
Attributes.ts(1, 25): This type parameter might need an `extends object` constraint.