bugger.
All challenges/TypeScripteasythe-default-that-never-runs-v1
THE INVESTIGATION

The default that never runs

A typed tuple silently loses trailing defaulted fields.

TypeScript & RuntimeAbsenceNormalization

What’s going wrong

A tuple parser promises exactly three strings: a required name, a role defaulting to "guest", and a tier defaulting to "standard". Inputs are a JSON array of dense arrays with zero to three elements. A missing trailing slot uses its default; a present value must be a string, including empty strings. null, numbers, booleans, objects and arrays are invalid. Return one {"ok":[name,role,tier]} per valid tuple, or {"error":index} for its first invalid or missing required slot. The first slot has no default. Preserve tuple order. An empty batch returns [].

Read one JSON value from stdin and print the specified JSON result to stdout. No actual network or external package is used.

Expected behavior

Distinguish a parser accepting an absent input from a parser producing a complete output.

Reproduction

01 Missing trailing defaults
[["Ada"]]
[{"ok":["Ada","guest","standard"]}]
02 Complete tuple control
[["Ada","admin","gold"]]
[{"ok":["Ada","admin","gold"]}]
03 Explicit null is invalid
[["Ada",null]]
[{"error":1}]

Before you begin

  • Start with tuple positions, required inputs and defaults that exist only at runtime.
  • TypeScript unions, arrays, objects and functions
  • Trace runtime behavior even when the program type-checks

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.