Open yarscript opened 1 month ago
https://www.typescriptlang.org/docs/handbook/utility-types.html
export abstract class BaseEntity<T> { constructor(options: Partial<T>) { Object.keys(options).forEach((k) => (this[k] = options[k])); } } export class Favour extends BaseEntity<Favour> { id: string; title: string; price: string; // constructor(options: Partial<Order>) { // Object.keys(options).forEach((k) => (this[k] = options[k])); // } // constructor(title: string, price: string) { // this.title = title; // this.price = price; // } } new Favour({ price: '23' });
type generics
@yarscript
https://www.typescriptlang.org/docs/handbook/utility-types.html
type generics