Consider the following class:
class Person {
name: string = 'Shachar';
age: number = 22;
printPerson() {
console.log(`name: ${this.name}, age: ${this.age}`);
}
}
Is there a way to get an interface with the properties that would be "own" by an instance of this class?
In this example, I want only the properties name and age, since printPerson will end up being part of the prototype of any instance, not own property.
Solutions that requires typing "name" and "age" explicitly are NOT acceptable since the class may have many properties and I would like to write them only once.
fooproperty, that might be good enough. With the dynamic nature of objects, it also doesn't make sense to restrict where and howfoocomes about.Personthat excludes all properties that are functions. However, that is not only going to remove prototype methods but also instance properties with assigned functions to them.