converted code to typescript syntax