Skip to content

Commit 0808eea

Browse files
committed
refactor(patterns): Migrate JSDoc types to TypeScript
1 parent 8334a56 commit 0808eea

File tree

13 files changed

+850
-724
lines changed

13 files changed

+850
-724
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ api-docs
101101
!packages/far/src/exports.d.ts
102102
!packages/lp32/types.d.ts
103103
!packages/pass-style/src/types.d.ts
104+
!packages/patterns/types.d.ts
104105
!packages/ses/src/reporting-types.d.ts
105106
!packages/ses/types.d.ts
106107
!packages/stream/types.d.ts

packages/patterns/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ export {
7575
getInterfaceMethodKeys,
7676
} from './src/patterns/getGuardPayloads.js';
7777

78-
// eslint-disable-next-line import/export
79-
export * from './src/types.js';
80-
8178
// /////////////////////////// Deprecated //////////////////////////////////////
8279

8380
export {

packages/patterns/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
"main": "./index.js",
1919
"module": "./index.js",
2020
"exports": {
21-
".": "./index.js",
21+
".": {
22+
"types": "./types.d.ts",
23+
"default": "./index.js"
24+
},
2225
"./package.json": "./package.json"
2326
},
2427
"scripts": {

packages/patterns/src/patterns/types.js

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/// <reference types="ses"/>
2+
3+
import type { Rejector } from '@endo/errors/rejector.js';
4+
import type { Passable } from '@endo/pass-style';
5+
import type {
6+
MatcherNamespace,
7+
Pattern,
8+
GetRankCover,
9+
Kind,
10+
} from '../types.js';
11+
12+
/**
13+
* This factors out only the parts specific to each kind of Matcher. It is
14+
* encapsulated, and its methods can make the stated unchecked assumptions
15+
* enforced by the common calling logic.
16+
*/
17+
export type MatchHelper = {
18+
/**
19+
* Reports whether `allegedPayload` is valid as the payload of a CopyTagged
20+
* whose tag corresponds with this MatchHelper's Matchers.
21+
*/
22+
confirmIsWellFormed: (allegedPayload: Passable, reject: Rejector) => boolean;
23+
24+
/**
25+
* Assuming validity of `matcherPayload` as the payload of a Matcher corresponding
26+
* with this MatchHelper, reports whether `specimen` is matched by that Matcher.
27+
*/
28+
confirmMatches: (
29+
specimen: Passable,
30+
matcherPayload: Passable,
31+
reject: Rejector,
32+
) => boolean;
33+
34+
/**
35+
* Assumes this is the payload of a CopyTagged with the corresponding
36+
* matchTag. Return a RankCover to bound from below and above,
37+
* in rank order, all possible Passables that would match this Matcher.
38+
* The left element must be before or the same rank as any possible
39+
* matching specimen. The right element must be after or the same
40+
* rank as any possible matching specimen.
41+
*/
42+
getRankCover: GetRankCover;
43+
};
44+
45+
export type PatternKit = {
46+
confirmMatches: (
47+
specimen: any,
48+
patt: Passable,
49+
reject: Rejector,
50+
label?: string | number,
51+
) => boolean;
52+
matches: (specimen: any, patt: Pattern) => boolean;
53+
mustMatch: (specimen: any, patt: Pattern, label?: string | number) => void;
54+
assertPattern: (patt: Pattern) => void;
55+
isPattern: (patt: any) => boolean;
56+
getRankCover: GetRankCover;
57+
M: MatcherNamespace;
58+
kindOf: (specimen: Passable, reject: Rejector) => Kind | undefined;
59+
};

0 commit comments

Comments
 (0)