Last 12 weeks · 7 commits
5 of 6 standards met
Summary Parses the expression string inside the TypeScript type system, so unknown context keys and syntax errors surface at the call site instead of waiting for runtime. Inspired by prior art like codemix/ts-sql and ronami/HypeScript, adapted for whenexpr's VS Code-style grammar (including the RHS identifier-as-literal rule). Validation is layered — you pay only for what you need: Also exports so libraries can carry the static check into their own typed helpers (e.g. ). Changes New — type-level tokenizer, precedence-climbing parser, , , New — (flat + / nested) signature now validates via README "Type Safety" section + levels-of-checking table Type tests in (vitest typecheck mode enabled) Widened ctx in existing where unknown-key runtime behaviour is tested Test plan [x] — clean [x] — 150 tests, 0 type errors [x] — no issues [ ] Consumer smoke test: drop into a project, confirm tooltip errors for unknown keys 🤖 Generated with Claude Code
Summary Implements — a tiny, zero-dependency evaluator for when-clause expressions, inspired by VS Code's when clause contexts. The pipeline is , with as a convenience wrapper that composes the two. The grammar is a JS-expression subset: literals (boolean/number/string), identifiers (namespaced with or ), unary / / , logical / , equality ( / VS Code-style stringy RHS, / JS strict on full expressions), relational (`>=+-*/%evaluateWhen{ strict: true }pnpm testparseevaluateevaluateWhenresolveContextValuepnpm typecheckpnpm lintpnpm buildevaluateWhen('(((a b) && c) + foo) === 1', { a: false, b: true, c: true, foo: 0 })true` 🤖 Generated with Claude Code
Repository: antfu/whenexpr. Description: Tiny when-clause expression evaluator with full type-safty Stars: 33, Forks: 0. Primary language: TypeScript. License: MIT. Homepage: https://npmx.dev/package/whenexpr Latest release: v0.1.2 (2mo ago). Open PRs: 0, open issues: 0. Last activity: 2mo ago. Community health: 85%. Top contributors: antfu.