9.1 Strongly typed v/s loosely typed languages

Feature Strongly Typed Languages Loosely Typed Languages
Definition Variables are bound strictly to a specific data type. Variables are not bound strictly to a data type.
Type Safety Enforces type rules strictly; prevents unintended operations. Less strict; type conversions may happen automatically.
Error Detection Many type errors are caught at compile-time (if compiled). Errors may only appear at runtime due to implicit conversions.
Type Conversion Requires explicit casting (e.g., int → string). Performs implicit conversions (e.g., number → string automatically).
Example Languages Java, C#, Swift, Rust JavaScript, Python, PHP
Advantages Fewer runtime errors, better maintainability, more reliable code. Easier prototyping, faster to write, more flexible.
Disadvantages More verbose, requires explicit type handling. Higher chance of runtime bugs, harder to debug type-related issues.

9.2 What is Typescript?

Developed by Microsoft, TS is a strict syntactic superset of JS and adds optional static typing to the language.

image.png

Code of JS will work in TS but code of TS wont work in JS.

9.3 How does TS code runs?

TS never runs in the web-browser, the browser only understands JS.

image.png

There are many TS Compilers, common ones are:

  1. esbuild
  2. swc
  3. tsc (official)