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

mid Level
1
What are generics in TypeScript and how do you use them?
mid
generics
Generics allow creating reusable components that work with multiple types while maintaining type safety. They use type parameters (like <T>) that are specified when the component is used, enabling type inference and constraints.
2
What are type guards in TypeScript and how do you create custom ones?
mid
type-guards
Type guards are runtime checks that narrow types within conditional blocks. Built-in guards include typeof, instanceof, and in operators. Custom type guards are functions returning a type predicate (param is Type) to narrow types based on custom logic.
3
What are TypeScript's built-in utility types and when do you use them?
mid
utility-types
Utility types are built-in generic types that transform other types. Common ones include Partial<T> (all optional), Required<T> (all required), Pick<T,K> (select properties), Omit<T,K> (exclude properties), and Record<K,V> (object type).
4
How do TypeScript modules work and what's the difference between import types?
mid
modules
TypeScript supports ES6 modules with import/export syntax. Use 'import type' for type-only imports (erased at compile time). Declaration files (.d.ts) provide types for JavaScript libraries. Module resolution follows Node.js or bundler strategies.
5
What are enums in TypeScript and when should you use them vs union types?
mid
enums
Enums define named constants that can be numeric or string values. They exist at runtime as objects. Union types ('a' | 'b') are often preferred for string literals as they're lighter weight and better tree-shaken. Use enums when you need runtime access to values.