Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 32 lines · 1.0 KiB · at 2cc04ee

// Every problem in this file has a safe fix. The harness copies the project,// runs `tsus fix`, compares the result with expected/main.tsus, then builds// and runs it. Several fixes sit inside match arms, so their edits have to// map back through the macro expansion.import { Some, None, type Option } from "@tsus/runtime";const greeting = "hello";const raw: unknown = JSON.parse('{"name":"ada","visits":3}');const nickname = (name: string): Option<string> => (name === "ada" ? Some("countess") : None);const plainGreeting = (name: string): string => {  const text = `${greeting} ${name}`;  return text;};const describe = (name: string): string =>  match (nickname(name)) {    Some(nick) => `${greeting} ${name}, also known as ${nick}`,    None => (plainGreeting(name) === "" ? "nobody" : plainGreeting(name)),  };let visits = 0;for (const n of [1, 2]) {  visits += n;}console.log(describe("ada"));console.log(describe("grace"));console.log(visits !== 3 ? "miscounted" : "visits ok");console.log(JSON.stringify(raw));