typescript-transformer-handbook icon indicating copy to clipboard operation
typescript-transformer-handbook copied to clipboard

Usage question: Modify class prototype

Open LukasMachetanz opened this issue 4 years ago • 1 comments

Hi again!

I am wondering if it is possible to adjust the prototype of a class declaration? E.g. add specific properties? If anyone has an idea I would really appreciate it.

Thanks in advance. Greets, Lukas

LukasMachetanz avatar Jul 15 '20 21:07 LukasMachetanz

hey mate!

you could always update the prototype directly? find a class references and then update the prototype next to it.

class HelloWorld{}
HelloWorld.prototype.sayHello = () => console.log('hello')

const e = new HelloWorld();
e.sayHello()
``

itsdouges avatar Jul 24 '20 23:07 itsdouges