It can also be useful for documenting input types, so that bad data is not passed in, or document what kind of error will be thrown if bad data is passed.
Plain JavaScript does have types, but they are rather limited: boolean, number, string, object, Array, Symbol, Map, Set, BigInt (and perhaps a few other less common ones). The problem is that the language does not strictly enforce the types, allowing a variable of one type to be re-assigned to a completely different type, or comparing two variables of different types. Even operators like + can have a much different meaning when dealign with numbers, strings, or cases when you have number + string. That’s where TypeScript or any other strong typing helps, as it prevents the unexpected behaviors you can get with pure JS if you are not careful.