theory.ts

TypeScript Basics

What is TypeScript?

TypeScript is a superset of JavaScript that adds static typing and advanced tooling, making large-scale development safer and more maintainable.

  • TypeScript builds on JavaScript, providing type safety and modern features.
  • It compiles to plain JavaScript, ensuring compatibility with all JavaScript environments.
  • Used in both front-end (React, Angular) and back-end (Node.js) development.
// TypeScript Example: Enforcing types
function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet("Jake")); // Works
console.log(greet(42)); // Error: Argument must be a string