James Hickey's Blog

Looking At Software Related Ideas Using Short And To The Point Code Samples :)

Menu Close

Tag: decorators

TypeScript Decorators: Bind Constructor Parameters Automagically

The more I use TypeScript the more I really like it. I’m starting to use the advanced features – and realize how powerful they are. TypeScript decorators are one of those fantastic features that let’s you automate common tasks and apply them in a sort of “meta-programming” fashion.

One of the use-cases I built for a project at work was a class decorator to automate binding a constructor’s parameters as properties on the new object. Read more

Using TypeScript Decorators To Clean-Up Mixins

Lately I’ve been migrating a JavaScript framework I built (for a work client) over to TypeScript. The core UI components are built using mixins. Using jQuery extend(), the JavaScript code would have done something like:

var TextBox.prototype = $.extend({ ...some object with functions and state....}, CanDoExtraStuff, CanDoOtherCoolStuff);

One of the first things I was hoping TypeScript would allow was to clean this up and make it clearer what was going on.

Read more

© 2017 James Hickey's Blog. All rights reserved.

Theme by Anders Norén.