✨ Finalize and document the public API surface
Export the matcher builder types from the barrel and rename them off the internal Strict/Widening suffixes, so the type a factory returns is nameable: PrimitiveUnionMatcher/W, TaggedUnionMatcher/W, and the tagged-union factory types. Add TSDoc to every public symbol — the declarations carry it into the published package — and pin the exported names in src/index.test.ts. Document the API in README and record the surface decision (and the rejected matcher-shared export) in development/library.md.
This commit is contained in:
1 parent
acf9d06ddd
commit
f485b1bae2
8 files changed
+317
-20
No files matched your search
+35
-2
@@ -5,8 +5,41 @@ user-facing reference is [README § API](../README.md#api).
|
||||
|
||||
The matchers are implemented in `src/primitive-union.ts` (`getPrimitiveUnionMatcher` /
|
||||
`getPrimitiveUnionMatcherW`) and `src/tagged-union.ts` (`getTaggedUnionMatcher` /
|
||||
`getTaggedUnionMatcherW`), re-exported from `src/index.ts`; the rest of the
|
||||
library is placeholder code.
|
||||
`getTaggedUnionMatcherW`), re-exported from `src/index.ts`; the rest of `src/`
|
||||
is implementation detail.
|
||||
|
||||
## Public surface
|
||||
|
||||
#### Decision (2026-09)
|
||||
|
||||
`src/index.ts` exports the four factories and the builder types they return:
|
||||
`PrimitiveUnionMatcher` / `PrimitiveUnionMatcherW`, `TaggedUnionMatcher` /
|
||||
`TaggedUnionMatcherW`, and `TaggedUnionMatcherFactory` /
|
||||
`TaggedUnionMatcherWFactory`. Every exported symbol carries TSDoc. The
|
||||
universe-agnostic pieces in `matcher-shared.ts` stay internal.
|
||||
|
||||
#### Why
|
||||
|
||||
- The builder interfaces are already the inferred return types (they appear in
|
||||
the emitted `.d.ts`), so exporting them only makes them nameable — a consumer
|
||||
can annotate a factory result without restating its structure.
|
||||
- The `Strict` / `Widening` suffixes were dropped for the public names because
|
||||
the factory names already carry the `W` axis; the type and function names line
|
||||
up (`getPrimitiveUnionMatcher` → `PrimitiveUnionMatcher`).
|
||||
- TSDoc travels into the emitted declarations, so editor hovers and the
|
||||
published package document the API without a hand-written `.d.ts`.
|
||||
- `matcher-shared.ts` stays internal: its types are plumbing (`Handlers`,
|
||||
`Fallback`, `UniverseGate`, …) whose shape follows the implementation, and the
|
||||
matchers are the stable contract.
|
||||
|
||||
#### Rejected
|
||||
|
||||
- **Exporting the `matcher-shared.ts` vocabulary** (`Matchable`, `UnaryFn`,
|
||||
`PatternKey`, `Member`, `PatternReturns`, …). They appear in the public
|
||||
signatures, but a consumer never needs to name them; exporting them would
|
||||
freeze internals as API.
|
||||
- **A hand-written `.d.ts` or a separate API document.** It would drift from the
|
||||
implementation; TSDoc is generated from the source.
|
||||
|
||||
## Matcher shape
|
||||
|
||||
|
||||
Reference in new issue
Block a user