Programming languages enthusiast. Author of Learn Type Driven Development: https://www.packtpub.com/application-development/learn-type-driven-development
I highly recommend writing a helper function which returns an instance of the class. This lets you exactly control the return type. For example, that's how I prefer to do private fields/methods/etc.:
// dog.tsexportinterfaceDog{speak():string}// The helper is exported and ensures that only the interface (public) fields are shownexportfunctionnewInstance(name:string):Dog{returnnewImpl(name)}// The class is hiddenclassImpl{constructor(name:string){this.name=name}speak():string{return'Woof!'}name:string}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I highly recommend writing a helper function which returns an instance of the class. This lets you exactly control the return type. For example, that's how I prefer to do private fields/methods/etc.: