Explore static types, runtime validation, generics and precise modeling of application state.
Four self-study difficulty levels, from basic concepts to advanced scenarios. Difficulty is an editorial guide, not an official certification ranking. Modern TypeScript with strict checking enabled unless a question states otherwise. Runtime examples follow JavaScript semantics; compiler types are not runtime validators.
YOUR PRACTICE SPACE
Learn it. Test it. Understand it.
Recognize core concepts and trace a single step.
10 questions in Easy · one answer per question · no timer
Free, no account needed. Answers stay in this tab and reset on reload. This is self-study, not a proctored exam or certificate.
Choose the right challenge
Easy checks core concepts. Medium applies them to tasks. Hard examines edge cases and failure modes. Very advanced combines constraints such as concurrency, security and recovery. Start where you are comfortable; each level has its own attempt and result. These labels are editorial, not certification grades.
What you will learn
Separate compile-time guarantees from runtime behavior.
Model valid states with unions and preserve relationships with generics.
Recognize unsound assertions, mutable aliases and boundary-validation gaps.
Think through a real scenario
An API response arrives as unknown. Writing “as Customer” changes what the compiler assumes, but does not check that an id or name exists in the response. Validate the input at the boundary, handle failures explicitly, and only then return a typed Customer. Within the application, a discriminated union can represent loading, success and failure without allowing contradictory combinations of flags.
Turn your result into a study plan
For each missed question, write down the rule you overlooked and test it with a small example. Avoid memorizing an option’s position: understanding the behavior matters more than recognizing the wording. In exam mode explanations stay hidden until you submit; in practice mode use “Check answer” to see feedback immediately.
Read further
The questions and explanations are original EmuPath teaching material. These references provide background for further study; their publishers do not endorse this exam.
Found an ambiguous question? Include the track and question text in your correction report.
Sample TypeScript Programming questions with explanations
Preview one question from each difficulty level before choosing a practice session. These examples also appear in the question bank. Try answering first, then open the explanation to check your reasoning.
Easy: Compilation
What happens to an interface declaration when ordinary TypeScript is emitted as JavaScript?
It does not become a runtime interface object
It becomes a database table
It automatically validates every HTTP response
It creates a JavaScript class constructor
Show answer and explanation
It does not become a runtime interface object
Interfaces describe compile-time shapes and are erased from ordinary emitted JavaScript. Runtime validation or construction needs actual executable code rather than an interface declaration.
Medium: Generics
Why prefer function identity<T>(x: T): T over an any-to-any signature?
It preserves the relationship between input and return types
It validates all nested properties at runtime
It guarantees x is a string
It makes the function asynchronous
Show answer and explanation
It preserves the relationship between input and return types
The type parameter captures the input type and carries it to the return type. Any loses that useful relationship, while generics themselves do not provide runtime validation.
Hard: Exhaustiveness
A switch handles every case of a discriminated union. What can assigning its remaining value to never help detect later?
A newly added union member that the switch does not handle
Every exception thrown by any dependency
An unreachable database server
A memory leak in the JavaScript runtime
Show answer and explanation
A newly added union member that the switch does not handle
After complete narrowing, no possible member should remain. If a new case is added without handling it, the assignment to never can expose the incomplete switch during checking.
Very advanced: Conditional types
For type Box<T> = T extends string ? {text:T} : {other:T}, what happens when T is a union and is a naked type parameter?
The conditional distributes over its union members
It always selects only the last union member
It evaluates by running typeof in the browser
It always returns never for a union
Show answer and explanation
The conditional distributes over its union members
Conditional types distribute in this form, applying the condition to each union member. Wrapping the compared types in tuples is a common way to request a non-distributive comparison.