What is TypeScript? And why use it ?
TypeScript is a syntactic superset of JavaScript which adds static typing.
This basically means that TypeScript adds syntax on top of JavaScript, allowing developers to add types.
allows specifying the types of data being passed around within the code, and has the ability to report errors when the types don’t match.
For example, TypeScript will report an error when passing a string into a function that expects a number. JavaScript will not.
What are the benefits of using TypeScript over plain JavaScript?
-catching errors during development
-providing better tooling and autocompletion
-enabling easier refactoring of code.
Explain the concept of static typing in TypeScript.
explicitly define types for variables, function parameters, and return values, helping catch type-related errors during compilation.
How do you define types and interfaces in TypeScript?
Types and interfaces in TypeScript allow you to define the structure and shape of objects, providing better documentation and enforcing type checks.
What are generics in TypeScript and how can they be helpful?
Generics in TypeScript allow you to create reusable components or functions that can work with different types.
How does TypeScript handle union and intersection types?
Union types in TypeScript allow a variable to have more than one type, while intersection types combine multiple types into a single type.
What are the basic data types in TypeScript?
What is a class in TypeScript?
What is an interface in TypeScript?
What is a module in TypeScript?
What is type inference in TypeScript?
Type inference is a feature in TypeScript that allows the compiler to automatically determine the type of a variable based on its value.
What is type assertion in TypeScript?
What is the difference between “interface” and “type” in TypeScript?
What is the difference between “any” and “unknown” in TypeScript?
pros of typescript
code that has less errors
cleaner
more readable
client and server side
optional
what is a tuple?
A tuple is a typed array with a pre-defined length and types for each index.
what is a tuple?
A tuple is a typed array with a pre-defined length and types for each index.