TypeScript Interfaces and Type Aliases Quiz
A 40-question TypeScript quiz covering interfaces, type aliases, structural typing, merging behavior, call signatures, index signatures, intersections, unions, and interface augmentation.
Question 1
Which keyword is used to declare an interface in TypeScript?
Question 2
Which property is optional in this interface?
interface User { id: number; name?: string; active: boolean; }Question 3
What does readonly do inside an interface?
Question 4
What error occurs here?
interface Point { readonly x: number; y: number; }
const p: Point = { x: 1, y: 2 };
p.x = 3;Question 5
Interfaces use which typing model?
Question 6
Which keyword creates a type alias?
Question 7
What is the type of value?
type Result = number | string;
let value: Result;Question 8
Which statement about type aliases is true?
Question 9
Which type is represented?
type Pair = [number, string];Question 10
Which feature is supported by interfaces but not type aliases?
Question 11
What does this extend?
interface A { x: number }
interface B extends A { y: number }Question 12
Which statement is true comparing interfaces and type aliases?
Question 13
What does this interface define?
interface Calc { (a: number, b: number): number }Question 14
Which option defines a method inside an interface?
Question 15
What is the return type?
type Fn = (msg: string) => boolean;Question 16
What does an index signature allow?
Question 17
What type do values have?
interface Bag { [key: string]: number }Question 18
Which constraint applies to index signatures?
Question 19
What does an intersection type do?
Question 20
What properties does Combined have?
type A = { x: number }
type B = { y: string }
type Combined = A & B;Question 21
Unions allow which behaviour?
Question 22
What type is Status?
type Status = 'success' | 'error' | 'loading';Question 23
What is declaration merging?
Question 24
What fields exist after merging?
interface Box { size: number }
interface Box { weight: number }Question 25
Which statements can interfaces extend?
Question 26
What does this produce?
type A = { a: number }
interface B extends A { b: string }Question 27
Which is a benefit of using interfaces?
Question 28
Type aliases are especially useful for:
Question 29
Which approach models a discriminated union?
Question 30
Which statement about intersections is correct?
Question 31
What is the purpose of interface augmentation?
Question 32
Which pattern helps unify two compatible types?
Question 33
Which can describe a function type?
Question 34
Which is true about optional interface fields?
Question 35
Which type construct allows creating aliases for primitive types?
Question 36
A property conflict in interface extension produces:
Question 37
Which describes structural typing?
Question 38
Why prefer interfaces for public API shapes?
Question 39
Which is NOT possible with type aliases?
Question 40
Which scenario favors using a type alias?
