Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 27 lines · 735 B · at 358de06

import { Ok, Err, type Result, type Option } from "@tsus/runtime";const parse = (raw: string): Result<number, number> =>  raw === "" ? Err(400) : Ok(raw.length);// An arm returns a number where the function promises a string.const label = (raw: string): string =>  match (parse(raw)) {    Ok(n) => n * 2,    Err(code) => `error ${code}`,  };// The Err payload is a number, so it has no toUpperCase.const shout = (raw: string): string =>  match (parse(raw)) {    Ok(n) => `${n}`,    Err(code) => code.toUpperCase(),  };// Some is misspelled: the subject has no variant called Sme.const first = (o: Option<string>): string =>  match (o) {    Sme(s) => s,    None => "none",  };console.log(label, shout, first);