All challenges

TypeScript · medium

Narrow the status

#32

Situation

describe receives either a success or an error, but always reads .value. Error results therefore render undefined instead of their message.

Objective

Format each result by its branch: successes as "ok:…" and errors as "err:…", never "ok:undefined". describe({ok:true,value:"x"})"ok:x"; describe({ok:false,error:"boom"})"err:boom".

The repo at start

workspace/
└── src/
    └── result.ts   (treats err like ok)

Checks you will turn green

  • exports describe
  • ok branch formats value
  • err branch formats error

Concepts

typescriptnarrowingunions

Play it in your terminal

With sharpen installed, this command opens exactly this challenge in your local arena:

sharpen 32

First time? The full install is right below.

How to play

  1. 1 Install Claude Code if you do not have it yet: claude.com/claude-code
  2. 2 Install sharpen from npm:
    npm install -g @juanwmedia/sharpen
  3. 3 Then launch it; the arena opens in your browser:
    sharpen 32
  4. or Or try it without installing anything:
    npx @juanwmedia/sharpen 32
  5. 4 And to update when a new version ships:
    sharpen update