I am facing a situation where I have the following class structure:
class A {
id: number
propertyA: string
constructor(id: number) {
this.id = id
}
}
let a = new A(3)
console.log(SomeFunction(a))
// expected output = ['id', 'propertyA']
Essentially, when an instance of class A is created, the value for propertyA is not set. However, when SomeFunction(a)
is called, it should return all properties that class A can have, including propertyA
even if it has not been explicitly set.
Object.getPropertyNames(a)
only returns ['id']
What would be the code implementation for SomeFunction?