From 246f4d7e99d86ff4a6c0bc9926bb7b97a957788b Mon Sep 17 00:00:00 2001 From: gvergnaud Date: Sun, 15 Dec 2024 22:20:02 -0500 Subject: [PATCH] doc: add missing docstrings --- src/patterns.ts | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/patterns.ts b/src/patterns.ts index 0daa17d2..3f9422f0 100644 --- a/src/patterns.ts +++ b/src/patterns.ts @@ -1,3 +1,10 @@ +/** + * The `P` module contains patterns for primitive types, wildcards and + * other pattern-matching utilities. + * + * @module + */ + import { matchPattern, getSelectionKeys, flatMap } from './internals/helpers'; import * as symbols from './internals/symbols'; import { matcher } from './internals/symbols'; @@ -37,17 +44,31 @@ import { NonNullablePattern, } from './types/Pattern'; -export type { Pattern, Fn as unstable_Fn }; +export type { + /** + * `Pattern` is the type of all patterns + * that can match a value of type `T`. + */ + Pattern, + + /** + * `unstable_Fn` can be used to created a + * a Matchable instance – a custom type that + * can be used as a pattern. + * + * @experimental This feature is unstable. + */ + Fn as unstable_Fn, +}; export { matcher }; /** - * @experimental * A `Matchable` is an object implementing * the Matcher Protocol. It must have a `[P.matcher]: P.Matcher` * key, which defines how this object should be matched by TS-Pattern. * - * Note that this api is unstable. + * @experimental This feature is unstable. * * @example * ```ts @@ -63,11 +84,10 @@ export type unstable_Matchable< > = CustomP; /** - * @experimental * A `Matcher` is an object with `match` function, which * defines how this object should be matched by TS-Pattern. * - * Note that this api is unstable. + * @experimental This feature is unstable. * * @example * ```ts