idk, maybe it is wrong, go to the http://www.typescriptlang.org/Playground/ to see how they do it, their code is pretty good.