LearnThatStack Ace your next interview
Frontend Development
TypeScript.
99 Qs 14 free
Change topic Change
Drill · questions

All questions

of 99
Beginner 17
01

What are the main benefits of using TypeScript over JavaScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • Early error detection: Catches type-related errors at compile time
  • Better developer experience: Enhanced IntelliSense and autocomplete
  • Improved maintainability: Self-documenting code through type annotations
  • Refactoring confidence: Safe refactoring with type checking
  • Team collaboration: Clear contracts between different parts of the codebase
  • Modern JavaScript features: Access to latest ES features with backward compatibility
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

02

How do you compile TypeScript code?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

TypeScript code is compiled using the TypeScript compiler (tsc):

# Install TypeScript globally
npm install -g typescript

# Compile a single file
tsc app.ts

# Compile with watch mode
tsc app.ts --watch

# Compile using tsconfig.json
tsc

The compiler reads .ts files and outputs .js files that can run in any JavaScript environment.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

03

What is type inference in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Type inference is TypeScript's ability to automatically determine types without explicit type annotations. The compiler analyzes the code and infers the most appropriate types.

let message = "Hello"; // TypeScript infers string type
let count = 42; // TypeScript infers number type
let isActive = true; // TypeScript infers boolean type

function add(a: number, b: number) {
  return a + b; // Return type inferred as number
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

04

What are type annotations and how do you use them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Type annotations are explicit type declarations that tell TypeScript what type a variable, parameter, or return value should be.

// Variable annotations
let username: string = "john";
let age: number = 25;
let isLoggedIn: boolean = false;

// Function parameter and return type annotations
function greet(name: string): string {
  return `Hello, ${name}!`;
}

// Array annotations
let numbers: number[] = [1, 2, 3];
let names: Array<string> = ["Alice", "Bob"];
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

05

What are the primitive types in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

TypeScript supports all JavaScript primitive types plus additional ones:

  • string: Text data
  • number: Numeric values (integers and floats)
  • boolean: True/false values
  • null: Intentional absence of value
  • undefined: Uninitialized value
  • symbol: Unique identifiers
  • bigint: Large integers
  • void: Absence of return value
  • never: Values that never occur
  • any: Disables type checking
  • unknown: Type-safe alternative to any
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

06

What is an interface in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An interface defines the structure of an object, specifying what properties and methods it should have.

interface User {
  id: number;
  name: string;
  email: string;
  isActive?: boolean; // Optional property
  readonly createdAt: Date; // Read-only property
}

const user: User = {
  id: 1,
  name: "John Doe",
  email: "john@example.com",
  createdAt: new Date()
};
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

07

How do you extend interfaces in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Use the extends keyword to inherit properties from other interfaces:

interface Shape {
  color: string;
}

interface Circle extends Shape {
  radius: number;
}

interface Rectangle extends Shape {
  width: number;
  height: number;
}

// Multiple inheritance
interface TimestampedShape extends Shape, Timestamped {
  area: number;
}

interface Timestamped {
  createdAt: Date;
  updatedAt: Date;
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

08

What are optional properties and how do you define them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Optional properties are marked with ? and may or may not be present in the object:

interface Config {
  apiUrl: string;
  timeout?: number; // Optional
  retries?: number; // Optional
  debug?: boolean; // Optional
}

const config: Config = {
  apiUrl: "https://api.example.com"
  // Other properties can be omitted
};

// Function with optional parameters
function createUser(name: string, age?: number): User {
  return {
    name,
    age: age ?? 18 // Default value if not provided
  };
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

09

What are readonly properties in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Readonly properties can only be assigned during initialization and cannot be modified afterward:

interface Point {
  readonly x: number;
  readonly y: number;
}

const point: Point = { x: 10, y: 20 };
// point.x = 30; // Error: Cannot assign to 'x' because it is read-only

// Readonly arrays
const readonlyArray: readonly number[] = [1, 2, 3];
// readonlyArray.push(4); // Error: Property 'push' does not exist

// ReadonlyArray type
const numbers: ReadonlyArray<number> = [1, 2, 3];
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

10

How do you define a class in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Classes in TypeScript include type annotations and access modifiers:

class Person {
  // Properties
  private _id: number;
  protected name: string;
  public email: string;

  constructor(id: number, name: string, email: string) {
    this._id = id;
    this.name = name;
    this.email = email;
  }

  // Methods
  public greet(): string {
    return `Hello, I'm ${this.name}`;
  }

  protected getId(): number {
    return this._id;
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

11

What are access modifiers in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

TypeScript provides three access modifiers:

  • public (default): Accessible everywhere
  • private: Accessible only within the same class
  • protected: Accessible within the class and its subclasses
class BankAccount {
  public accountNumber: string;
  private balance: number;
  protected accountType: string;

  constructor(accountNumber: string, initialBalance: number) {
    this.accountNumber = accountNumber;
    this.balance = initialBalance;
    this.accountType = "savings";
  }

  public getBalance(): number {
    return this.balance; // Accessing private property within class
  }

  private calculateInterest(): number {
    return this.balance * 0.05;
  }
}

class PremiumAccount extends BankAccount {
  constructor(accountNumber: string, initialBalance: number) {
    super(accountNumber, initialBalance);
    // this.balance; // Error: private property
    console.log(this.accountType); // OK: protected property
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

12

How do ES6 modules work in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

TypeScript fully supports ES6 module syntax for importing and exporting:

// math.ts
export function add(a: number, b: number): number {
  return a + b;
}

export function subtract(a: number, b: number): number {
  return a - b;
}

export default function multiply(a: number, b: number): number {
  return a * b;
}

export const PI = 3.14159;

// app.ts
import multiply, { add, subtract, PI } from './math';
import * as MathUtils from './math';

console.log(add(5, 3)); // 8
console.log(multiply(4, 2)); // 8
console.log(MathUtils.PI); // 3.14159
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

13

What is `NonNullable<T>` utility type?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

NonNullable<T> removes null and undefined from a type:

type MaybeString = string | null | undefined;
type DefinitelyString = NonNullable<MaybeString>; // string

function processValue(value: string | null | undefined): void {
  if (value !== null && value !== undefined) {
    // Type narrowing
    const processed: NonNullable<typeof value> = value; // string
    console.log(processed.toUpperCase());
  }
}

// Useful with arrays
type ArrayItem<T> = T extends (infer U)[] ? NonNullable<U> : never;
type StringArrayItem = ArrayItem<(string | null)[]>; // string
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

14

How do you handle errors in TypeScript?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

TypeScript supports JavaScript's error handling mechanisms with additional type safety:

// Basic try-catch
function parseNumber(value: string): number {
  try {
    const parsed = parseInt(value);
    if (isNaN(parsed)) {
      throw new Error(`Invalid number: ${value}`);
    }
    return parsed;
  } catch (error) {
    if (error instanceof Error) {
      console.error(error.message);
    }
    throw error;
  }
}

// Custom error types
class ValidationError extends Error {
  constructor(
    message: string,
    public field: string,
    public value: any
  ) {
    super(message);
    this.name = 'ValidationError';
  }
}

function validateEmail(email: string): void {
  if (!email.includes('@')) {
    throw new ValidationError('Invalid email format', 'email', email);
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

15

How do you stay updated with TypeScript evolution?

Part of Pro
16

What advice would you give to someone learning TypeScript?

Part of Pro
17

What are your thoughts on TypeScript's future and ecosystem?

Part of Pro
Intermediate 53
18

What is the difference between `any` and `unknown` types?

Part of Pro
19

Explain union types and intersection types

Part of Pro
20

What are literal types in TypeScript?

Part of Pro
21

How do you handle nullable types in TypeScript?

Part of Pro
22

What is type assertion and when should you use it?

Part of Pro
23

What's the difference between `interface` and `type` in TypeScript?

Part of Pro
24

How do you define function types in interfaces?

Part of Pro
25

What are index signatures in TypeScript?

Part of Pro
26

How does inheritance work in TypeScript?

Part of Pro
27

What are abstract classes in TypeScript?

Part of Pro
28

How do you implement interfaces in classes?

Part of Pro
29

What are static methods and properties in TypeScript?

Part of Pro
30

What are getters and setters in TypeScript?

Part of Pro
31

What are generics in TypeScript and why are they useful?

Part of Pro
32

How do you define generic interfaces?

Part of Pro
33

What are generic constraints in TypeScript?

Part of Pro
34

How do you create generic classes?

Part of Pro
35

What is the `keyof` operator in TypeScript?

Part of Pro
36

What are discriminated unions in TypeScript?

Part of Pro
37

What is type narrowing in TypeScript?

Part of Pro
38

What are type guards in TypeScript?

Part of Pro
39

What is the `never` type in TypeScript?

Part of Pro
40

What are namespaces in TypeScript?

Part of Pro
41

What's the difference between namespaces and modules?

Part of Pro
42

How do you handle module resolution in TypeScript?

Part of Pro
43

What are utility types in TypeScript?

Part of Pro
44

Explain `Record<K, T>` utility type

Part of Pro
45

What are `ReturnType<T>` and `Parameters<T>` utility types?

Part of Pro
46

How do you use `Exclude<T, U>` and `Extract<T, U>`?

Part of Pro
47

How do you debug TypeScript code?

Part of Pro
48

What is strict mode in TypeScript?

Part of Pro
49

What is tsconfig.json and what are its important options?

Part of Pro
50

How do you configure TypeScript for different environments?

Part of Pro
51

What are TypeScript declaration files (.d.ts)?

Part of Pro
52

How do you integrate TypeScript with build tools?

Part of Pro
53

What are TypeScript coding best practices?

Part of Pro
54

How do you handle gradual TypeScript adoption?

Part of Pro
55

What are common TypeScript anti-patterns to avoid?

Part of Pro
56

What are effective TypeScript testing strategies?

Part of Pro
57

How does TypeScript work with React?

Part of Pro
58

How do you type React event handlers?

Part of Pro
59

How does TypeScript work with Node.js?

Part of Pro
60

How do you handle async/await with TypeScript?

Part of Pro
61

How do you handle API responses with TypeScript?

Part of Pro
62

How do you implement type-safe form validation?

Part of Pro
63

How do you handle state management with TypeScript?

Part of Pro
64

How do you write type-safe tests in TypeScript?

Part of Pro
65

How do you implement real-time features with TypeScript?

Part of Pro
66

What are some common TypeScript gotchas?

Part of Pro
67

How do you handle TypeScript in a team environment?

Part of Pro
68

What are your favorite TypeScript utility types and why?

Part of Pro
69

What TypeScript patterns do you use for error handling?

Part of Pro
70

How do you use the `satisfies` operator in TypeScript 5+?

Part of Pro
Expert 29
71

What are conditional types in TypeScript?

Part of Pro
72

What are mapped types in TypeScript?

Part of Pro
73

Explain template literal types in TypeScript

Part of Pro
74

What are index access types in TypeScript?

Part of Pro
75

What are decorators in TypeScript?

Part of Pro
76

What are class decorators in TypeScript?

Part of Pro
77

How do property decorators work?

Part of Pro
78

What are assertion functions in TypeScript?

Part of Pro
79

How do you optimize TypeScript compilation performance?

Part of Pro
80

How do you structure large TypeScript projects?

Part of Pro
81

What are template literal types used for?

Part of Pro
82

How do you implement builder patterns with TypeScript?

Part of Pro
83

What are higher-order types in TypeScript?

Part of Pro
84

How do you implement type-safe event systems?

Part of Pro
85

What are phantom types in TypeScript?

Part of Pro
86

How do you implement functional programming patterns with TypeScript?

Part of Pro
87

How do you optimize TypeScript bundle size?

Part of Pro
88

What are the performance implications of different TypeScript features?

Part of Pro
89

How do you implement dependency injection with TypeScript?

Part of Pro
90

How do you ensure type safety in large codebases?

Part of Pro
91

How do you handle type migrations in evolving APIs?

Part of Pro
92

How do you use TypeScript in microservices architecture?

Part of Pro
93

What would you consider when migrating a large JavaScript project to TypeScript?

Part of Pro
94

What are the most challenging TypeScript concepts you've worked with?

Part of Pro
95

How do you debug complex TypeScript type errors?

Part of Pro
96

How do you implement design patterns with TypeScript?

Part of Pro
97

How do you handle performance optimization in TypeScript applications?

Part of Pro
98

What are decorators in TypeScript 5+ and how do you use them?

Part of Pro
99

How do you implement const assertions and template literal types effectively?

Part of Pro

No matches

Try a different filter or search term.

Pro · $10/mo

85 of 99 TypeScript answers are gated.

Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.

  • Full answers + code
  • AI explain - simpler, deeper, or visualized
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

JAM

JavaScript, APIs, and Markup

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

Web3 / Ethereum

Solidity, Ethereum, Hardhat, Foundry

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git
Complexity Analysis Arrays Strings Hashing Linked Lists Stacks Queues Trees Heaps Graphs Core Algorithms Operating Systems Concurrency Multithreading Networking Fundamentals Git API Design 45 Distributed Systems Fundamentals 34