Advertisement
Guest User

Untitled

a guest
Mar 14th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interface ICustomer {
  2.     name: string;
  3. }
  4.  
  5. class CustomerClass {
  6.     constructor(data: ICustomer) {
  7.         Object.assign(this, data)
  8.     }
  9.  
  10.     get self() {
  11.         return this as any as ICustomer
  12.     }
  13.  
  14.     bar() {
  15.         console.log(this.self.name)
  16.     }
  17. }
  18.  
  19. type Customer = CustomerClass & ICustomer
  20.  
  21. function Customer(data: ICustomer): Customer {
  22.     const ret = new CustomerClass(data);
  23.  
  24.     return ret as Customer;
  25. }
  26.  
  27. export {Customer, ICustomer}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement