CRM-13397 js.common also backport js ts function, other changes are only formatting