Added generic typing and converted to TS 0.9 module