Sobes.tech
Middle

What is TypeScript? What is it used for?

sobes.tech AI

Answer from AI

TypeScript is a superset of JavaScript that adds static typing and modern language features. It compiles to plain JavaScript, which can run in any browser or environment.

Main goals of TypeScript:

  • Provide static typing, which helps catch errors at compile time rather than at runtime.
  • Improve support for development tools: autocompletion, refactoring, code navigation.
  • Allow the use of modern language features and syntax that may not be supported in all environments.

Example:

function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet("World"));

Here, the name parameter is strictly typed as a string, preventing the passing of incorrect types.

What is TypeScript? What is it used for? — Frontend - sobes.tech