9e03c524732ec8757b4617a44ce2130059185c8a
A handler's `expectTypeOf(shape)` only proved the type the compiler inferred; nothing observed the argument `dispatch` passed. Passing `String(shape)` at the call site therefore kept the whole suite green while breaking every key whose property name differs from its value (`true`, `null`, `1`). Pair each handler expectation with a runtime assertion: `assert.equal` where a handler runs for one shape, the disjunction over the set a `_` fallback accepts where it runs for several. Where the exact value matters the fallback returns its shape verbatim and the call site asserts it; a widening pattern absorbs the remainder type into the return union, so the claim stays strict-free. The mutation above now fails 10 of the 33 tests. Rule: CONTRIBUTING.md, rationale: development/testing.md § Handler arguments.
tiny-pattern-ts
Pattern matching for TypeScript/ESM environments (F#-style, not regex).
Description
tiny-pattern-ts brings F#-style pattern matching to TypeScript. Patterns are
ordinary objects whose matches method is a TypeScript type guard, so narrowing
composes the way any other guard does. It is deliberately not a regex engine and
not a macro: there is no transpiler and no DSL to learn, and the type-level
contract is the feature — see development/library.md
for the design decisions and Caveats for the limits.
Requirements
- Node.js >= 26 (
enginesfield; pinned via.node-version). - TypeScript >= 5.0 to consume the published declarations. The emitted
.d.tsuseconsttype parameters (TS 5.0) and keep their relative.tsspecifiers; both resolve on TS >= 5.0 innode10/node16/nodenext/bundler. - The package is ESM-only (no CommonJS shim).
API
Yet to be implemented
Caveats
- A value and its stringification collide. Object keys stringify, so a
universe that mixes a member with the string it stringifies to —
1 | "1",true | "true",null | "null"— collapses to a single handler key and both members are routed to it. Use one form or the other. symbolandbigintare not supported. Asymbolbrand is a compile-time phantom with nothing to match at runtime, and abigintis not a valid property key; neither satisfies the matcher's universe constraint.NaNand-0cannot be matched specifically. They have no literal type, so both stay part ofnumber.
License
MIT © 2025 tmu. See LICENSE.
Contributing
Contributions are documented in CONTRIBUTING.md; the reasons behind the project's decisions, rejected alternatives, and known issues live in development/. AI coding agents start at AGENTS.md.