Evaluating TypeScript proficiency requires going beyond simple JavaScript algorithms with added type annotations. Strong candidates demonstrate type-safe design patterns, zero unnecessary any usage, and proper generic constraints.
Problem 1: Strongly Typed Event Emitter
Implement a type-safe event emitter where event names map to expected payload argument types.
class TypedEventEmitter
on
emit
// Usage Example: interface AppEvents { userLogin: { userId: string; timestamp: number }; error: { message: string }; }
const emitter = new TypedEventEmitter
Problem 2: Type-Safe Result Union (Result<T, E>)
Model success and error outcomes without relying on thrown exceptions.
type Result<T, E = Error> =
| { ok: true; value: T }function ok
function err
Problem 3: DeepReadonly<T> Utility Type
type DeepReadonly<T> = T extends Function
? T
: T extends object
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
: T;Problem 4: TypeScript Code Review Challenge
Spot the anti-patterns in the following snippet:
// Flawed implementation:
async function fetchUser(id: any): Promise<any> {
const res = await fetch(`/users/${id}`);
const data = await res.json();
return data as any;
}Issues: Heavy reliance on any, lack of error boundary check on res.ok, and unsafe type assertions.
*Explore the Bad TypeScript Design code review problem on Pairlet.*
---
Practice TypeScript Interviews Run TypeScript coding interviews in a collaborative browser workspace with real-time feedback. [Create a free Pairlet interview room](https://www.pairlet.dev/interview/new).
Frequently Asked Questions
Why test TypeScript specific problems instead of plain JavaScript?
TypeScript coding problems evaluate how candidates construct maintainable type contracts, avoid 'any' escape hatches, handle nullability, and model domain data accurately at compile time.
Conduct Live Coding Interviews with Zero Friction
No candidate sign-up required. Create an instant room, share the link, and code together in real time with shared code execution.