docs: document all 19 modules + fix(types): make documented patterns compile - #8
Merged
Conversation
Type-only changes — zero runtime behavior change, all 1079 tests pass.
- Union.match/is/get/partition/groupBy: infer from the union value
(U extends { tag; value }) instead of Union<T>, which the compiler
cannot invert — the documented destructuring match pattern previously
failed to compile against the published d.ts under strict mode
- These.isLeft/isRight/isBoth: now type guards that narrow to the
Left/Right/Both member
- Eq.struct / Ord.struct: constraint relaxed to A extends object so
interfaces are accepted (Record<string, unknown> rejected them)
- tsconfig.test.json: inherited exclude nullified the tests include, so
tests were never typechecked; add explicit exclude + vitest/globals
- tests: adapt union tests to as-Shape literals (assignment narrowing),
fix noUncheckedIndexedAccess access in these tests
- JSDoc examples in function/record/these/union corrected to versions
that actually compile (verified against the packaged build)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
All code examples were extracted, typechecked (strict + exactOptionalPropertyTypes + noUncheckedIndexedAccess) and executed against the npm-packed build. - CLAUDE.md: add the 8 previously undocumented modules (function, eq, ord, predicate, array, these, tree, record) with API reference - README.md: expand fp module sections to full API; fix These example (toResult needs These<AppError[], A>), Union.of example, and the fromAsync/bindIfAsync signatures shown; document the as-Shape literal pattern for exhaustive Union.match - AGENTS.md: add string module, HttpCodes, Result.traverse, Union.partition/groupBy, pattern sections for the 8 fp modules, and new naming-pitfall rows (assignment narrowing, These error arrays, fromAsync takes Promise<Result<T>>) - docs/index.html: add tsentials/string module card and case-conversion example, make snippets self-contained, fix the These/Ord/Maybe/Rules examples, embed the Context7 chat widget - prose pass: rewrite dash-spliced sentences and clipped fragments into plain sentences across all four files Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two commits:
fix(types)— type-only, zero runtime change, 1079/1079 tests passUnion.match/is/get/partition/groupBynow infer from the union value (U extends { tag; value }) instead ofUnion<T>, which the compiler cannot invert. The documented destructuringmatchpattern previously did not compile against the published d.ts under strict mode.These.isLeft/isRight/isBothare now narrowing type guards.Eq.struct/Ord.structaccept interfaces (A extends object).tsconfig.test.json: the inheritedexclude: ["tests"]nullified its include, so tests were never typechecked. Fixed, plusvitest/globalstypes. (~67 pre-existing test type errors are now visible; tracked as follow-up, runtime tests unaffected.)function/record/these/unioncorrected to versions that compile.docs— all four docs updated, every example verifiedThese,Union.of,fromAsync, andbindIfAsyncexamples; documents theas Shapeliteral pattern (assignment narrowing breaks exhaustive match).Result.traverse,Union.partition/groupBy, pattern sections for the fp modules, new pitfall rows.tsentials/stringcard + example, self-contained snippets, Context7 chat widget.Verification
Every example was extracted into a scratch project, installed from the
npm packtarball, typechecked withstrict+exactOptionalPropertyTypes+noUncheckedIndexedAccess, and executed with runtime assertions. Repo: build, 1079 tests, biome, and src typecheck all green.Note: npm's 0.1.10 still ships the old (broken) Union typings — a 0.1.11 release is needed for consumers to get the fix.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com