docs/roadmap.md
P.ExactPattern<Type> to infer the exact pattern you must write to fully cover all possible properties of Type.isMatching with a type parameter to restrain the pattern type: isMatching<Type>(pattern)..narrow() as an opt-in option to narrow the input type after a .withP.array.includes(x)P.record({Pkey}, {Pvalue})P.recordP.unknown alias to any.P.nonNullableP.string.includes('str')P.string.startsWith('str')P.string.endsWith('str')P.string.regex('[a-z]+')P.number.between(1, 10)P.number.lt(12)P.number.gt(12)P.number.gte(12)P.number.lte(12)P.number.int(12)P.number.finiteP.number.positiveP.number.negativeP.number.optionalP.string.optionalP.number.select()P.string.select()P.number.optional.select()P.string.optional.select()P.array to be usable as a variadic tuple pattern. Example of using P.array:const reverse = <T>(xs: T[]): T[] => {
return match<T[], T[]>(xs)
.with([P.any, ...P.array()], ([x, ...xs]) => [...reverse(xs), x])
.otherwise(() => []);
};
match(xs)
.with([P.any, ...P.array()], (xs: [unknown, ...unknown[]]) => [])
.with([42, ...P.array(P.number), '!'], (xs: [42, ...number[], '!']) => [])
.with(
[...P.array(P.number), ...P.array(P.string)],
(xs: [...number[], ...string[]]) => []
)
.otherwise(() => []);
select() and select('name') to accept a pattern the selected value should match.union(...patterns) pattern.select API for single values.with() clause.not(value) in patterns.when if the predicate is a type guard.