All questions
of 99What are the main benefits of using TypeScript over JavaScript?
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:
Last attempt -
- 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
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 →
How do you compile TypeScript code?
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:
Last attempt -
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.
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 →
What is type inference in TypeScript?
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:
Last attempt -
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
}
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 →
What are type annotations and how do you use them?
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:
Last attempt -
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"];
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 →
What are the primitive types in TypeScript?
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:
Last attempt -
TypeScript supports all JavaScript primitive types plus additional ones:
string: Text datanumber: Numeric values (integers and floats)boolean: True/false valuesnull: Intentional absence of valueundefined: Uninitialized valuesymbol: Unique identifiersbigint: Large integersvoid: Absence of return valuenever: Values that never occurany: Disables type checkingunknown: Type-safe alternative to any
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 →
What is an interface in TypeScript?
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:
Last attempt -
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()
};
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 →
How do you extend interfaces in TypeScript?
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:
Last attempt -
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;
}
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 →
What are optional properties and how do you define them?
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:
Last attempt -
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
};
}
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 →
What are readonly properties in TypeScript?
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:
Last attempt -
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];
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 →
How do you define a class in TypeScript?
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:
Last attempt -
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;
}
}
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 →
What are access modifiers in TypeScript?
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:
Last attempt -
TypeScript provides three access modifiers:
public(default): Accessible everywhereprivate: Accessible only within the same classprotected: 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
}
}
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 →
How do ES6 modules work in TypeScript?
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:
Last attempt -
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
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 →
What is `NonNullable<T>` utility type?
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:
Last attempt -
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
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 →
How do you handle errors in TypeScript?
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:
Last attempt -
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);
}
}
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 →
How do you stay updated with TypeScript evolution?
What advice would you give to someone learning TypeScript?
What are your thoughts on TypeScript's future and ecosystem?
What is the difference between `any` and `unknown` types?
Explain union types and intersection types
What are literal types in TypeScript?
How do you handle nullable types in TypeScript?
What is type assertion and when should you use it?
What's the difference between `interface` and `type` in TypeScript?
How do you define function types in interfaces?
What are index signatures in TypeScript?
How does inheritance work in TypeScript?
What are abstract classes in TypeScript?
How do you implement interfaces in classes?
What are static methods and properties in TypeScript?
What are getters and setters in TypeScript?
What are generics in TypeScript and why are they useful?
How do you define generic interfaces?
What are generic constraints in TypeScript?
How do you create generic classes?
What is the `keyof` operator in TypeScript?
What are discriminated unions in TypeScript?
What is type narrowing in TypeScript?
What are type guards in TypeScript?
What is the `never` type in TypeScript?
What are namespaces in TypeScript?
What's the difference between namespaces and modules?
How do you handle module resolution in TypeScript?
What are utility types in TypeScript?
Explain `Record<K, T>` utility type
What are `ReturnType<T>` and `Parameters<T>` utility types?
How do you use `Exclude<T, U>` and `Extract<T, U>`?
How do you debug TypeScript code?
What is strict mode in TypeScript?
What is tsconfig.json and what are its important options?
How do you configure TypeScript for different environments?
What are TypeScript declaration files (.d.ts)?
How do you integrate TypeScript with build tools?
What are TypeScript coding best practices?
How do you handle gradual TypeScript adoption?
What are common TypeScript anti-patterns to avoid?
What are effective TypeScript testing strategies?
How does TypeScript work with React?
How do you type React event handlers?
How does TypeScript work with Node.js?
How do you handle async/await with TypeScript?
How do you handle API responses with TypeScript?
How do you implement type-safe form validation?
How do you handle state management with TypeScript?
How do you write type-safe tests in TypeScript?
How do you implement real-time features with TypeScript?
What are some common TypeScript gotchas?
How do you handle TypeScript in a team environment?
What are your favorite TypeScript utility types and why?
What TypeScript patterns do you use for error handling?
How do you use the `satisfies` operator in TypeScript 5+?
What are conditional types in TypeScript?
What are mapped types in TypeScript?
Explain template literal types in TypeScript
What are index access types in TypeScript?
What are decorators in TypeScript?
What are class decorators in TypeScript?
How do property decorators work?
What are assertion functions in TypeScript?
How do you optimize TypeScript compilation performance?
How do you structure large TypeScript projects?
What are template literal types used for?
How do you implement builder patterns with TypeScript?
What are higher-order types in TypeScript?
How do you implement type-safe event systems?
What are phantom types in TypeScript?
How do you implement functional programming patterns with TypeScript?
How do you optimize TypeScript bundle size?
What are the performance implications of different TypeScript features?
How do you implement dependency injection with TypeScript?
How do you ensure type safety in large codebases?
How do you handle type migrations in evolving APIs?
How do you use TypeScript in microservices architecture?
What would you consider when migrating a large JavaScript project to TypeScript?
What are the most challenging TypeScript concepts you've worked with?
How do you debug complex TypeScript type errors?
How do you implement design patterns with TypeScript?
How do you handle performance optimization in TypeScript applications?
What are decorators in TypeScript 5+ and how do you use them?
How do you implement const assertions and template literal types effectively?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
TypeScript cheatsheet
TypeScript Frontend Interview Cheat Sheet
- Summary01
- 1. TypeScript Basics02
- 2. Interfaces & Types03
- 3. Functions04
- 4. Classes05
- 5. Generics06
- 6. Advanced Types07
- 7. Utility Types08
- 8. Enums09
- 9. Modules10
- 10. React with TypeScript11
- 11. Advanced Patterns12
- + 10 more inside
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.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsLAMP
Linux, Apache, MySQL, PHPRuby on Rails
Convention over ConfigurationJAM
JavaScript, APIs, and MarkupServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemInterviewers also test these - they're common to every stack, whichever one you picked above.
Vue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQFastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseWeb3 / Ethereum
Solidity, Ethereum, Hardhat, FoundryDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.