add typescript compiler
some refactoring