Use Object.defineProperty

More correct, and setting prototype directly breaks WebStorm 9.
Added support for @typedef