TISTUD-6750 Javascript indexing isn't aware of constructor functions for generating types

A series of commits to make us more aware of using constructor functions, the 'this' keyword and other ways of hanging properties off types.
Basically we used to handle standard object literal syntax to generate a new 'type'. Now we also handle use of constructor functions, including nested scopes referring to differing 'this' objects. We assume the wrapping function/object is the 'this' binding.