How to get around property does not exist on ‘Object’

Posted by Ramesh Singh | Updated on

Want to get around property does not exist on ‘Object’? If you use the any type instead of Object, you can access any property without compile errors. However, I would advise to create an interface that marks the possible properties for that object:

Since all of the fields use ?:, it means that they might or might not be there. So this works:

If something comes from javascript, you can do something like this:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers