Made with Palestinian hands Support EmuPath ☕

No results found.

Try another search or remove some filters.

All practice exams
Programming / FOUR DIFFICULTY LEVELS

TypeScript Programming

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.

Choose your difficulty

Recognize core concepts and trace a single step.

10 questions in Easy · one answer per question · no timer

Choose a mode

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?

  1. It does not become a runtime interface object
  2. It becomes a database table
  3. It automatically validates every HTTP response
  4. 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?

  1. It preserves the relationship between input and return types
  2. It validates all nested properties at runtime
  3. It guarantees x is a string
  4. 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?

  1. A newly added union member that the switch does not handle
  2. Every exception thrown by any dependency
  3. An unreachable database server
  4. 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?

  1. The conditional distributes over its union members
  2. It always selects only the last union member
  3. It evaluates by running typeof in the browser
  4. 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.