Difference between == and === in TypeScript
Hello everyone! Please explain to a TypeScript beginner: what is the fundamental difference between the == and === operators? I read that in JavaScript the first one does type coercion, while the second one is strict comparison, but in TypeScript, as I understand, types are already strictly controlled by the compiler.
Here's an example that confuses me:
const a: number = 5;\nconst b: string = "5";\n\nif (a == b) {\n console.log("Equal with ==");\n}\n\nif (a === b) {\n console.log("Equal with ===");\n}The first if outputs a message, the second does not. I expected TypeScript to not even allow me to compare number and string without explicit type conversion, but the code compiles. Why is that? Shouldn't TypeScript throw an error on a == b?