TypeScript Interview Questions

TypeScript Interview Questions

🟢 Basic Level (1–20)

  1. What is TypeScript?
  2. Who developed TypeScript?
  3. Is TypeScript a programming language?
  4. Difference between TypeScript and JavaScript?
  5. Why do we use TypeScript?
  6. What are the features of TypeScript?
  7. How does TypeScript compile?
  8. What is static typing?
  9. What is type inference?
  10. What is the file extension of TypeScript?
  11. What is tsconfig.json?
  12. What is type annotation?
  13. What is any type?
  14. What is unknown type?
  15. Difference between any and unknown?
  16. What are primitive types in TypeScript?
  17. What is boolean, number, string types?
  18. What is void type?
  19. What is never type?
  20. What is null and undefined?

⚙️ Core Concepts (21–40)

  1. What are interfaces in TypeScript?
  2. Difference between interface and type alias?
  3. What is optional property?
  4. What are arrays in TypeScript?
  5. What are tuples?
  6. What are enums?
  7. What is union type?
  8. What is intersection type?
  9. What are literals in TypeScript?
  10. What is type narrowing?
  11. What is type assertion?
  12. What is type casting?
  13. What are generics?
  14. Why use generics?
  15. What is function typing?
  16. What are arrow functions in TypeScript?
  17. What is overload function?
  18. What is default parameter?
  19. What is rest parameter?
  20. What is object typing?

🧱 OOP & Advanced Concepts (41–60)

  1. What is OOP in TypeScript?
  2. What is class in TypeScript?
  3. What are constructors?
  4. What is inheritance?
  5. What is polymorphism?
  6. What is encapsulation?
  7. What are access modifiers?
  8. Difference between public, private, protected?
  9. What is abstract class?
  10. What are interfaces used for in OOP?
  11. What are getters and setters?
  12. What is static keyword?
  13. What is method overriding?
  14. What is method overloading?
  15. What is namespace?
  16. What is module in TypeScript?
  17. What is import/export?
  18. What is decorators?
  19. What are metadata in TypeScript?
  20. What is compilation target?

⚡ Advanced Level (61–80)

  1. What is structural typing?
  2. What is duck typing?
  3. What is type compatibility?
  4. What is mapped type?
  5. What is conditional type?
  6. What is keyof operator?
  7. What is typeof operator in TS?
  8. What is indexed access type?
  9. What is utility types in TypeScript?
  10. Name common utility types (Partial, Pick, Omit, etc.)
  11. What is Partial<T>?
  12. What is Required<T>?
  13. What is Readonly<T>?
  14. What is Record<K, T>?
  15. What is Exclude<T, U>?
  16. What is Extract<T, U>?
  17. What is NonNullable<T>?
  18. What is ReturnType<T>?
  19. What is Parameters<T>?
  20. What is type guards?

🚀 Scenario-Based (81–100)

  1. How does TypeScript improve JavaScript?
  2. How does TypeScript prevent runtime errors?
  3. How to migrate JS project to TS?
  4. How does TypeScript compile to JavaScript?
  5. How to configure tsconfig.json?
  6. How to enable strict mode?
  7. How to handle API response typing?
  8. How to type React props in TypeScript?
  9. How to use TypeScript with Node.js?
  10. How to debug TypeScript code?
  11. How to handle errors in TypeScript?
  12. How to use TypeScript in large projects?
  13. How does TypeScript improve code maintainability?
  14. Difference between compile-time and runtime?
  15. How to use interfaces in real projects?
  16. What are best practices in TypeScript?
  17. What are common TypeScript mistakes?
  18. How to optimize TypeScript performance?
  19. Why use TypeScript with React or Angular?
  20. Why companies prefer TypeScript?

TypeScript Interview Answers (Q1–100)

🟢 Basic (1–20)

  1. TypeScript is a typed superset of JavaScript
  2. Microsoft developed TypeScript
  3. No, it is a superset of JavaScript
  4. TS has types, JS is dynamically typed
  5. To reduce runtime errors and improve code quality
  6. Static typing, interfaces, OOP support
  7. It compiles to JavaScript using tsc
  8. Types defined before runtime
  9. Type is automatically detected
  10. .ts
  11. Configuration file for TypeScript compiler
  12. Defining type for variables
  13. Any type disables type checking
  14. Unknown requires type checking before use
  15. Any = no safety, Unknown = safe
  16. number, string, boolean, etc.
  17. Basic primitive data types
  18. Function returns nothing
  19. Function never returns value
  20. null = empty, undefined = not assigned

⚙️ Core (21–40)

  1. Blueprint of object
  2. Interface = object structure, type = flexible alias
  3. Optional property uses “?”
  4. Same type elements collection
  5. Fixed-length mixed-type array
  6. Named constant values
  7. Multiple possible types
  8. Combine multiple types
  9. Fixed values
  10. Refining types
  11. Forcing type conversion
  12. Similar to assertion but unsafe
  13. Reusable type parameters
  14. Code reusability
  15. Function with types
  16. Function shorthand syntax
  17. Same function multiple signatures
  18. Default value parameter
  19. Variable number of arguments
  20. Object structure typing

🧱 OOP (41–60)

  1. Object-oriented programming
  2. Blueprint for objects
  3. Initializes object
  4. Inherits properties
  5. One function, multiple forms
  6. Data hiding
  7. Access control keywords
  8. Public = open, private = restricted, protected = subclass only
  9. Class with abstract methods
  10. Define structure
  11. Get/set values
  12. Class-level member
  13. Redefining method
  14. Same function different parameters
  15. Grouping code (deprecated mostly)
  16. ES module system
  17. Sharing code
  18. Special function metadata
  19. Extra class information
  20. ES target version

⚡ Advanced (61–80)

  1. Shape-based typing
  2. Same as structural typing
  3. Type compatibility rules
  4. Create new types from existing
  5. Type based on condition
  6. Gets keys of type
  7. Gets type of variable
  8. Access nested types
  9. Predefined helper types
  10. Partial, Pick, Omit, Record etc.
  11. Makes all properties optional
  12. Makes all required
  13. Makes all readonly
  14. Creates object type
  15. Excludes types
  16. Extracts matching types
  17. Removes null/undefined
  18. Return type of function
  19. Function parameter types
  20. Type checking conditions

🚀 Scenario (81–100)

  1. Adds type safety
  2. Catches errors at compile time
  3. Rename files + add tsconfig
  4. TS → JS compiler output
  5. Config compiler options
  6. Enables strict checking
  7. Define interface for API data
  8. Use interface for props typing
  9. Use ts-node or compilation
  10. Use debugger + compiler errors
  11. Try/catch + strict typing
  12. Better structure + safety
  13. Reduces bugs
  14. Compile vs execution time
  15. Define reusable structures
  16. Use strict mode, interfaces
  17. Overusing any type
  18. Avoid unnecessary types
  19. Better scalability and safety
  20. Safer and scalable development