StaffCoder
TypeScript
Vanilla TypeScriptTypeScript 7.0
6 modules · 24 challengesSign up
Modules6 modules · 24 challenges
Structure a small TypeScript codebase across modules the way a real front end does. The topic covers splitting helpers into cohesive named-export packages with an acyclic import graph and no window writes, centralising configuration behind a single accessor module that hides a raw global from every consumer, dynamic import() for lazy code-splitting with deduped concurrent calls and success caching (but no cached failures), and shared bootstrap plus per-view entries whose init functions are idempotent — safe to call multiple times without duplicating listeners or work. The runtime tests enforce the seams: no side effects at import time, no global mutation, no duplicated registrations on repeat init.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

4 challenges

Storefront Utilities Package

Sign up to unlock
—No data yeteasy
About this challenge

Split a monolithic entry into three named-export modules — format (formatPrice, formatSavingsPercent), validate (isValidEmail), and dom (setText, setDisabled) — and wire them from a thin entry inside a single DOMContentLoaded handler. No file may assign to window, importing any helper in isolation must not touch the document, and the helper import graph must have no cycles.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

Storefront Config Module

Sign up to unlock
—No data yeteasy
About this challenge

Write config.ts — DEFAULTS, UnknownConfigKeyError, getConfig, and the generically-typed getConfigValue<K>(key) — as the single seam between a raw window.__STOREFRONT_CONFIG__ object and every consumer. Defaults document absent keys, injected values (including false and "") win over defaults, the returned object is frozen, unknown keys throw the named error, and no consumer file references the raw global.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

Analytics Chart Loader

Sign up to unlock
—No data yeteasy
About this challenge

Implement createChartLoader(importFn) and the default loadChart so a heavy chart module is only fetched via import('./chart') when the user clicks Load. The loader dedupes concurrent calls to a single in-flight promise, caches the resolved module for every future call, and does not cache failures so Retry starts clean. The entry never references ./chart statically.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

Shared Storefront Bootstrap

STAR
Solving it completes the module
—No data yeteasy
About this challenge

Write bootstrap.ts, homeEntry.ts, and productEntry.ts so nothing runs at import time. initBootstrap() runs its work exactly once no matter how many entries invoke it; each entry's init() writes only to its own view and registers only its own click listener; and any init() is safe to call multiple times without duplicating listeners or double-writing text. Idempotency lives in module-scope let flags; no file assigns to window.

Read the full problem
Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.