TypeScriptTinyIoC : Inversion of Control and Domain Events for TypeScript

Topics: General
Mar 27, 2013 at 2:35 PM
I have just uploaded an initial version of TypeScriptTinyIoC to github : typescript-tiny-ioc.

This is an implementation of an Inversion of Control Container for TypeScript.

This version includes
  • Service location via Interfaces
  • Domain Events design pattern
  • A SampleApp showing both in practice
  • Jasmine unit tests
  • Backbone.js
  • Handlebars.js
Any feedback would be appreciated.
Apr 1, 2013 at 5:49 PM
Doesn't the IInterfaceChecker have to exist for every single interface (in duplicate)?
class IIConfigSettingsService implements IInterfaceChecker {
    className: string = 'IIConfigSettingsService';
    methodNames: string[] = ['storeSetting', 'readSetting'];
Apr 3, 2013 at 1:53 PM
Hey nabog,
The IInterfaceChecker only needs to exist for the classes that you register with TypeScriptTinyIoC.
TypeScript will do compile-time checking to ensure that classes implement TypeScript interfaces.
The IInterfaceChecker is a design pattern to ensure run-time implementation of an interface, and is a TypeScript implementation of the pattern found in Ross Harmes' and Dustin Diaz' book Pro JavaScript Design Patterns.
Apr 3, 2013 at 3:16 PM
Edited Apr 3, 2013 at 3:19 PM
What if the TypeScript compiler generated actual JavaScript classes for each interface? Then there wouldn't be any need for IInterfaceChecker, right?

Something along the lines of
  interface IFoo {
would compile into
 IFoo = function IFoo() {

 IFoo.prototype.foo = function () {}; // Empty implementation
It would then be possible to figure out if a type implemented a particular interface by comparing with the properties of the generated IFoo.