JS Guide
HomeQuestionsSearchResources
Search

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionstypescript

typescript

TypeScript types, generics, and advanced type programming

Your Progress

0 of 5 completed

0%

5 Questions

senior Level
1
How do conditional types work in TypeScript?
senior
conditional-types
Conditional types select types based on conditions using the syntax T extends U ? X : Y. They enable type-level programming, allowing different types based on input. Combined with infer, they can extract and transform types dynamically.
2
How do mapped types work in TypeScript?
senior
mapped-types
Mapped types transform existing types by iterating over their keys using 'in keyof' syntax. They can modify properties (make optional, readonly), rename keys, and filter properties. Built-in utilities like Partial, Required, and Pick use mapped types.
3
What are template literal types and how do you use them?
senior
template-literal-types
Template literal types use the same syntax as template strings but operate on types. They can create union types from string combinations, validate string patterns, and transform string types. Useful for type-safe event names, CSS properties, and API routes.
4
How do you handle complex generic constraints and variance in TypeScript?
senior
advanced
Complex constraints use multiple extends, conditional types, and recursive patterns. Variance determines how type parameters relate in subtyping: covariant (out), contravariant (in), invariant (both), and bivariant (neither). Understanding variance helps design safe generic APIs.
5
How do you write declaration files for JavaScript libraries?
senior
declarations
Declaration files (.d.ts) provide type information for JavaScript code without implementation. They use 'declare' keyword for ambient declarations, support module augmentation for extending existing types, and global augmentation for adding to global scope.