TypeScript Type Operators

In TypeScript, type operators are constructs that allow you to perform operations on types. These operators provide powerful mechanisms for defining and manipulating types in a flexible and expressive manner.

Name Description Syntax
typeof Obtains the type of a variable, function, or property. let x = 10;<br>type XType = typeof x;<br>// XType is 'number'
keyof Obtains the keys (property names) of a type. type Person = { name: string; age: number };<br>type PersonKeys = keyof Person;<br>`// PersonKeys is ‘name’
Mapped Types Allows creating new types based on the properties of existing types. type Optional<T> = { [K in keyof T]?: T[K] };
Conditional Types Allows expressing a type based on a condition. type TypeName<T> = T extends string ? 'string' : 'non-string';

TypeScript Operators

TypeScript operators are symbols or keywords that perform operations on one or more operands. In this article, we are going to learn various types of TypeScript Operators.

Below are the different TypeScript Operators:

Table of Content

  • TypeScript Arithmetic operators
  • TypeScript Logical operators
  • TypeScript Relational operators
  • TypeScript Bitwise operators
  • TypeScript Assignment operators
  • TypeScript Ternary/conditional operator
  • TypeScript Type Operators
  • TypeScript String Operators

Similar Reads

TypeScript Arithmetic operators

In TypeScript, arithmetic operators are used to perform mathematical calculations....

TypeScript Logical operators

In TypeScript, logical operators are used to perform logical operations on Boolean values....

TypeScript Relational operators

In TypeScript, relational operators are used to compare two values and determine the relationship between them....

TypeScript Bitwise operators

In TypeScript, bitwise operators perform operations on the binary representation of numeric values....

TypeScript Assignment operators

In TypeScript, assignment operators are used to assign values to variables and modify their values based on arithmetic or bitwise operations....

TypeScript Ternary/conditional operator

In TypeScript, the ternary operator, also known as the conditional operator, is a concise way to write conditional statements. It allows you to express a simple if-else statement in a single line....

TypeScript Type Operators

In TypeScript, type operators are constructs that allow you to perform operations on types. These operators provide powerful mechanisms for defining and manipulating types in a flexible and expressive manner....

TypeScript String Operators

In TypeScript, string operators and features are used for manipulating and working with string values....

Contact Us