InterviewPitch

Land the job you want — prepare
with Real interviews Q&A

Curated interview questions, company-wise guides and coding rounds. Practice mock interviews, improve with feedback, and track your progress.

Q&A
Top curated interview packs
Company-wise & role-wise packs, quality assured.
Mock interview
AI scoring
Coding rounds
Top 10 sets
Beginner
1. What is TypeScript?

TypeScript is a strongly typed programming language built on top of JavaScript.

TypeScript adds features like:

  • Static typing
  • Interfaces
  • Generics
  • Better tooling and autocomplete
typescript
let username: string = "AK";
let age: number = 25;
let isLoggedIn: boolean = true;
Beginner
2. Why use TypeScript?

TypeScript helps developers catch errors early during development.

Benefits of TypeScript
  • Better code quality
  • Type safety
  • Easy maintenance
  • Improved IntelliSense
  • Scalable for large applications
Beginner
3. What are types in TypeScript?

Types define what kind of value a variable can store.

typescript
let username: string = "AK";
let age: number = 25;
let isLoggedIn: boolean = true;
Beginner
4. What is any type?

The any type disables TypeScript type checking.

typescript
let value: any = "Hello";

value = 10;
value = true;

// any disables type checking
Beginner
5. What is unknown type?

unknown is a safer alternative to any.

typescript
let value: unknown = "Hello";

if (typeof value === "string") {
  console.log(value.toUpperCase());
}

// unknown is safer than any
Beginner
6. What are arrays in TypeScript?

Arrays store multiple values of the same type.

typescript
let numbers: number[] = [1, 2, 3];

let users: Array<string> = ["AK", "John"];

console.log(numbers);
console.log(users);
Beginner
7. What is tuple in TypeScript?

A tuple is a fixed-length array with specific types.

typescript
let user: [string, number] = ["AK", 25];

console.log(user[0]); // AK
console.log(user[1]); // 25
Intermediate
8. What is enum?

enum is used to define a set of named constants.

typescript
enum Role {
  Admin,
  User,
  Guest
}

let currentRole: Role = Role.Admin;

console.log(currentRole);
Intermediate
9. What is type alias?

Type aliases create custom reusable types.

typescript
type User = {
  name: string;
  age: number;
};

const user: User = {
  name: "AK",
  age: 25
};
Intermediate
10. What is interface?

Interfaces define the structure of an object.

typescript
interface Person {
  name: string;
  age: number;
}

const person: Person = {
  name: "John",
  age: 30
};
Intermediate
11. What are function types?

TypeScript allows you to define parameter and return types.

typescript
function greet(name: string): void {
  console.log("Hello " + name);
}

greet("AK");
Advanced
12. What are generics?

Generics allow reusable components that work with multiple types.

typescript
function identity<T>(value: T): T {
  return value;
}

console.log(identity<string>("Hello"));
console.log(identity<number>(100));
Advanced
13. What are classes in TypeScript?

Classes are blueprints for creating objects.

typescript
class Person {
  name: string;

  constructor(name: string) {
    this.name = name;
  }

  greet() {
    console.log("Hello " + this.name);
  }
}

const p1 = new Person("AK");
p1.greet();
Advanced
14. What is inheritance?

Inheritance allows one class to inherit properties and methods from another class.

typescript
class Animal {
  speak() {
    console.log("Animal speaks");
  }
}

class Dog extends Animal {
  bark() {
    console.log("Dog barks");
  }
}

const d = new Dog();

d.speak();
d.bark();
Advanced
15. What is intersection type?

Intersection types combine multiple types into one.

typescript
type Admin = {
  name: string;
};

type Employee = {
  id: number;
};

type AdminEmployee = Admin & Employee;

const user: AdminEmployee = {
  name: "AK",
  id: 101
};
Advanced
16. What are literal types?

Literal types allow exact values as types.

typescript
type Status = "success" | "error" | "loading";

let currentStatus: Status = "success";

// currentStatus = "done"; ❌ Error
Advanced
17. What are union types?

Union types allow multiple possible types.

typescript
function printId(id: number | string) {
  console.log(id);
}

printId(101);
printId("A101");
Advanced
18. What is optional chaining?

Optional chaining safely accesses nested properties.

typescript
function getValue(value: string | null) {
  console.log(value?.toUpperCase());
}

getValue("hello");
getValue(null);
Advanced
19. What are optional properties?

Optional properties are properties that may or may not exist.

typescript
interface User {
  name: string;
  age?: number;
}

const user1: User = {
  name: "AK"
};

const user2: User = {
  name: "John",
  age: 30
};
Advanced
20. What is type assertion?

Type assertion tells TypeScript the specific type of a value.

typescript
const button = document.getElementById("btn") as HTMLButtonElement;

button.addEventListener("click", () => {
  console.log("Clicked");
});
Advanced
21. What are generic interfaces?

Generic interfaces allow reusable typed structures.

typescript
interface ApiResponse<T> {
  data: T;
  success: boolean;
}

const response: ApiResponse<string> = {
  data: "User fetched",
  success: true
};