-
Notifications
You must be signed in to change notification settings - Fork 12.8k
non static function calls do not work if object is loaded from JSON using JSON.parse() #30564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Now I understand why it would happen, but isn't it the intended behaviour |
This is intended behavior as far as the language and the teams intention goes. A suggestion to you would be to replace the type of the
This way the method returns |
Thanks for the information. But since generics are supported in typescript, I am thinking, whether a Generic implementation can help in this context. I will give a try to your suggestion. As a workaround I have introduced static methods to my class and passing the instance for for any required operation. |
It looks like this is a question rather than a bug report. This issue tracker is for tracking bugs and active work on TypeScript itself, rather than a general forum for programmers using TypeScript to get help or ask questions. You can ask questions on sites like Stack Overflow. We are not able to provide one-on-one support on the issue tracker. Please read the issue template carefully - it has important information on what kinds of reports can be acted on here, as well as links to useful TypeScript resources. Thanks! |
To me, it absolutely looked like bug. In any other strongly typed language (say C#) this would work just fine, but not here. |
Uh oh!
There was an error while loading. Please reload this page.
Playground Link: Here
If a class is parsed from JSON data. Instance methods cannot be access anymore. Method calls fail silently without any logging. It works fine if class is created using "new ClassName()". Also works fine for static method calls.
The text was updated successfully, but these errors were encountered: