Skip to content

mtr-prabhat-sharma/Typescript-concepts

Repository files navigation

  1. Union: In Typescript, a union type is a special type which is denoted by pipe symbol (|) in which we can assign multiple types to a single variable.

  2. Enums: Enums allows us to define a set of named constants. TypeScript provides both numeric and string-based enums.

  3. Tuples: In TypeScript, a tuple is a data structure that allows you to define an ordered collection of elements, each with a specific type. Tuples are similar to arrays but have a fixed length and the types of their elements are known at compile time

  4. Type annotations: Type annotations are a crucial concept in TypeScript. They allow developers to specify the data types of variables, function parameters, and return types. This can help catch errors during development and improve code readability.

  5. Interfaces: In typescript Interfaces are used to define the structure of an object. The specify the name and type of object properties. It also helps in consistency across multiple objects.

  6. Generic: In typescript, Generic allow us to create resuable functions and classes that can work with different data types. They provide a powerful way to create reusable and type-safe code.

  7. Type Inference: It is a feature of Type Script that allows us to omit the type of variable. Type Script automatically inference the type of the variable on the basis of value assigned to the variable.