I have a TypeScript model which contains properties and functions like:
class Person {
name: string
sayHello(){ console.log(name); }
}
When creating its instance I can make use of this sayHello()
method as expected.
The problem comes when I store and get the object from the local storage or an external web service. While the properties are still present the methods have disappeared. (obviously because itβs just text).
Is there any way to restore the completeness of the object to be able to use its functions?
Or otherwise, is there any other technique? For instance, helper class that can work with type.