What is the result of the following TypeScript code snippet regarding type inference? let value = “Hello”; value = 42;

TypeScript Professional Easy

TypeScript Professional — Easy

What is the result of the following TypeScript code snippet regarding type inference? let value = “Hello”; value = 42;

Key points

  • TypeScript performs type inference based on initial values.
  • Variables inferred as a specific primitive type cannot be reassigned to a different primitive type.
  • Static type checking occurs at compile time, preventing type mismatches before execution.

Ready to go further?

Related questions