I'm just starting with TS and after reading the docs I have a few aspects I'm very confused about:
[1] Isn't var useless when const and let exist?
[2] Isn't == and != bad practise because it allows implicit type conversions, so should I always use === and !== instead?
[3] From what I read, someVar! / someVar as X and <X>someVar don't actually do any assertions or conversions, but instead tell the compiler to shut up about potential errors
[4] Static properties of classes aren't recognized as undefined if not initialized? For instance below, x has the type number instead of number | undefined
class Example { public static x: number;}
[5] There is no proper overloading? Instead one has to define a function which combines all functions to overload, where the parameters have to take on all possibilities of the overloaded function parameters and this ambiguity has to be handled in this combined function body...
[6] My biggest concern is with using object (and in turn type, interface), because it feels so loose, for instance:
interface Point { x: number, y: number }
interface WeirdPoint { x: number, y: number }
function Example(): Point | WeirdPoint {...}
const test = Example();
is there no way for me to know which type test has? Its type is object, but how shall I distinguish between it being a Point or a WeirdPoint?
Objects seem to obey the mantra "if it quacks like a duck then it's a duck" even when this leads to really confusing code where one must be cautious not to mismatch interfaces/types accidentally because they have similar arguments or when having a function that takes an object with Properties "a" and "b", maybe one accidentally now allowed a type one didn't know about elsewhere which has these two properties but wasn't intended for this purpose.