@agoric/async-flow 0.1.1-upgrade-16-dev-d492653.0 → 0.1.1-upgrade-17-dev-3b97a9f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +2 -0
  3. package/package.json +20 -19
  4. package/src/async-flow.d.ts +19 -12
  5. package/src/async-flow.d.ts.map +1 -1
  6. package/src/async-flow.js +31 -16
  7. package/src/bijection.d.ts +7 -4
  8. package/src/bijection.d.ts.map +1 -1
  9. package/src/bijection.js +90 -15
  10. package/src/convert.d.ts +1 -0
  11. package/src/convert.d.ts.map +1 -1
  12. package/src/convert.js +7 -5
  13. package/src/endowments.d.ts +16 -0
  14. package/src/endowments.d.ts.map +1 -0
  15. package/src/endowments.js +294 -0
  16. package/src/ephemera.d.ts +1 -0
  17. package/src/ephemera.d.ts.map +1 -1
  18. package/src/ephemera.js +4 -0
  19. package/src/equate.js +4 -4
  20. package/src/log-store.d.ts +4 -2
  21. package/src/log-store.d.ts.map +1 -1
  22. package/src/log-store.js +5 -1
  23. package/src/replay-membrane.d.ts +19 -50
  24. package/src/replay-membrane.d.ts.map +1 -1
  25. package/src/replay-membrane.js +218 -18
  26. package/src/type-guards.d.ts.map +1 -1
  27. package/src/type-guards.js +21 -7
  28. package/src/types.d.ts +211 -60
  29. package/src/types.js +1 -164
  30. package/test/async-flow-crank.test.js +6 -0
  31. package/test/async-flow-early-completion.test.js +2 -0
  32. package/test/async-flow-no-this.js +6 -0
  33. package/test/async-flow.test.js +5 -2
  34. package/test/bad-host.test.js +5 -0
  35. package/test/bijection.test.js +12 -6
  36. package/test/convert.test.js +5 -0
  37. package/test/endowments.test.js +157 -0
  38. package/test/equate.test.js +6 -2
  39. package/test/log-store.test.js +9 -1
  40. package/test/replay-membrane-eventual.test.js +134 -8
  41. package/test/replay-membrane-settlement.test.js +24 -5
  42. package/test/replay-membrane-zombie.test.js +43 -14
  43. package/test/replay-membrane.test.js +39 -13
  44. package/test/types.test-d.ts +73 -0
  45. package/tsconfig.json +2 -0
  46. package/src/types.d.ts.map +0 -1
@@ -7,6 +7,7 @@ import {
7
7
  } from './prepare-test-env-ava.js';
8
8
 
9
9
  import { Fail } from '@endo/errors';
10
+ import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
10
11
  import { prepareVowTools } from '@agoric/vow';
11
12
  import { E } from '@endo/eventual-send';
12
13
  // import E from '@agoric/vow/src/E.js';
@@ -18,6 +19,13 @@ import { prepareLogStore } from '../src/log-store.js';
18
19
  import { prepareBijection } from '../src/bijection.js';
19
20
  import { makeReplayMembrane } from '../src/replay-membrane.js';
20
21
 
22
+ /**
23
+ * @import {PromiseKit} from '@endo/promise-kit'
24
+ * @import {Zone} from '@agoric/base-zone'
25
+ * @import {LogStore} from '../src/log-store.js';
26
+ * @import {Bijection} from '../src/bijection.js';
27
+ */
28
+
21
29
  const watchWake = _vowish => {};
22
30
  const panic = problem => Fail`panic over ${problem}`;
23
31
 
@@ -39,15 +47,25 @@ const preparePingee = zone =>
39
47
  */
40
48
  const testFirstPlay = async (t, zone) => {
41
49
  const vowTools = prepareVowTools(zone);
50
+ const { makeVowKit } = vowTools;
42
51
  const makeLogStore = prepareLogStore(zone);
43
52
  const makeBijection = prepareBijection(zone);
44
53
  const makePingee = preparePingee(zone);
54
+ const { vow: v1, resolver: r1 } = zone.makeOnce('v1', () => makeVowKit());
55
+ const { vow: _v2, resolver: _r2 } = zone.makeOnce('v2', () => makeVowKit());
45
56
 
46
57
  const log = zone.makeOnce('log', () => makeLogStore());
47
- const bij = zone.makeOnce('bij', makeBijection);
48
-
49
- const mem = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
58
+ const bijection = zone.makeOnce('bij', makeBijection);
59
+
60
+ const mem = makeReplayMembrane({
61
+ log,
62
+ bijection,
63
+ vowTools,
64
+ watchWake,
65
+ panic,
66
+ });
50
67
 
68
+ const p1 = mem.hostToGuest(v1);
51
69
  t.deepEqual(log.dump(), []);
52
70
 
53
71
  /** @type {Pingee} */
@@ -56,18 +74,122 @@ const testFirstPlay = async (t, zone) => {
56
74
  const guestPingee = mem.hostToGuest(pingee);
57
75
  t.deepEqual(log.dump(), []);
58
76
 
59
- const pingTestSendResult = t.throwsAsync(() => E(guestPingee).ping('send'), {
60
- message:
61
- 'panic over "[Error: guest eventual send not yet supported: \\"[Alleged: Pingee guest wrapper]\\".ping([\\"send\\"]) -> \\"[Promise]\\"]"',
77
+ const p = E(guestPingee).ping('send');
78
+ const pOnly = E.sendOnly(guestPingee).ping('sendOnly');
79
+ t.is(pOnly, undefined);
80
+
81
+ guestPingee.ping('call');
82
+
83
+ t.is(await p, undefined);
84
+ const dump = log.dump();
85
+ const v3 = dump[3][2];
86
+ t.deepEqual(dump, [
87
+ ['checkCall', pingee, 'ping', ['call'], 0],
88
+ ['doReturn', 0, undefined],
89
+ ['checkSend', pingee, 'ping', ['send'], 2],
90
+ ['doReturn', 2, v3],
91
+ ['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
92
+ ['doFulfill', v3, undefined],
93
+ ]);
94
+
95
+ r1.resolve('x');
96
+ t.is(await p1, 'x');
97
+
98
+ t.deepEqual(log.dump(), [
99
+ ['checkCall', pingee, 'ping', ['call'], 0],
100
+ ['doReturn', 0, undefined],
101
+ ['checkSend', pingee, 'ping', ['send'], 2],
102
+ ['doReturn', 2, v3],
103
+ ['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
104
+ ['doFulfill', v3, undefined],
105
+ ['doFulfill', v1, 'x'],
106
+ ]);
107
+ };
108
+
109
+ /**
110
+ * @param {any} t
111
+ * @param {Zone} zone
112
+ */
113
+ const testReplay = async (t, zone) => {
114
+ const vowTools = prepareVowTools(zone);
115
+ prepareLogStore(zone);
116
+ prepareBijection(zone);
117
+ preparePingee(zone);
118
+ const { vow: v1 } = zone.makeOnce('v1', () => Fail`need v1`);
119
+ const { vow: v2, resolver: r2 } = zone.makeOnce('v2', () => Fail`need v2`);
120
+
121
+ const log = /** @type {LogStore} */ (
122
+ zone.makeOnce('log', () => Fail`need log`)
123
+ );
124
+ const bijection = /** @type {Bijection} */ (
125
+ zone.makeOnce('bij', () => Fail`need bij`)
126
+ );
127
+
128
+ const pingee = zone.makeOnce('pingee', () => Fail`need pingee`);
129
+
130
+ const dump = log.dump();
131
+ const v3 = dump[3][2];
132
+ t.deepEqual(dump, [
133
+ ['checkCall', pingee, 'ping', ['call'], 0],
134
+ ['doReturn', 0, undefined],
135
+ ['checkSend', pingee, 'ping', ['send'], 2],
136
+ ['doReturn', 2, v3],
137
+ ['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
138
+ ['doFulfill', v3, undefined],
139
+ ['doFulfill', v1, 'x'],
140
+ ]);
141
+
142
+ const mem = makeReplayMembrane({
143
+ log,
144
+ bijection,
145
+ vowTools,
146
+ watchWake,
147
+ panic,
62
148
  });
149
+ t.true(log.isReplaying());
150
+ t.is(log.getIndex(), 0);
151
+
152
+ const guestPingee = mem.hostToGuest(pingee);
153
+ const p2 = mem.hostToGuest(v2);
154
+ // @ts-expect-error TS doesn't know that r2 is a resolver
155
+ r2.resolve('y');
156
+ await eventLoopIteration();
157
+
158
+ const p1 = mem.hostToGuest(v1);
159
+ mem.wake();
160
+ t.true(log.isReplaying());
161
+ t.is(log.getIndex(), 0);
162
+ t.deepEqual(log.dump(), [
163
+ ['checkCall', pingee, 'ping', ['call'], 0],
164
+ ['doReturn', 0, undefined],
165
+ ['checkSend', pingee, 'ping', ['send'], 2],
166
+ ['doReturn', 2, v3],
167
+ ['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
168
+ ['doFulfill', v3, undefined],
169
+ ['doFulfill', v1, 'x'],
170
+ ]);
171
+
172
+ E(guestPingee).ping('send');
173
+ // TODO Once https://github.com/endojs/endo/issues/2336 is fixed,
174
+ // the following `void` should not be needed. But strangely, TS isn't
175
+ // telling me a `void` is needed above, which is also incorrect.
176
+ void E.sendOnly(guestPingee).ping('sendOnly');
63
177
 
64
178
  guestPingee.ping('call');
65
179
 
66
- await pingTestSendResult;
180
+ t.is(await p1, 'x');
181
+ t.is(await p2, 'y');
182
+ t.false(log.isReplaying());
67
183
 
68
184
  t.deepEqual(log.dump(), [
69
185
  ['checkCall', pingee, 'ping', ['call'], 0],
70
186
  ['doReturn', 0, undefined],
187
+ ['checkSend', pingee, 'ping', ['send'], 2],
188
+ ['doReturn', 2, v3],
189
+ ['checkSendOnly', pingee, 'ping', ['sendOnly'], 4],
190
+ ['doFulfill', v3, undefined],
191
+ ['doFulfill', v1, 'x'],
192
+ ['doFulfill', v2, 'y'],
71
193
  ]);
72
194
  };
73
195
 
@@ -87,5 +209,9 @@ test.serial('test durable replay-membrane settlement', async t => {
87
209
 
88
210
  nextLife();
89
211
  const zone1 = makeDurableZone(getBaggage(), 'durableRoot');
90
- return testFirstPlay(t, zone1);
212
+ await testFirstPlay(t, zone1);
213
+
214
+ nextLife();
215
+ const zone3 = makeDurableZone(getBaggage(), 'durableRoot');
216
+ return testReplay(t, zone3);
91
217
  });
@@ -17,6 +17,13 @@ import { prepareLogStore } from '../src/log-store.js';
17
17
  import { prepareBijection } from '../src/bijection.js';
18
18
  import { makeReplayMembrane } from '../src/replay-membrane.js';
19
19
 
20
+ /**
21
+ * @import {PromiseKit} from '@endo/promise-kit'
22
+ * @import {Zone} from '@agoric/base-zone'
23
+ * @import {LogStore} from '../src/log-store.js';
24
+ * @import {Bijection} from '../src/bijection.js';
25
+ */
26
+
20
27
  const watchWake = _vowish => {};
21
28
  const panic = problem => Fail`panic over ${problem}`;
22
29
 
@@ -42,9 +49,15 @@ const testFirstPlay = async (t, zone) => {
42
49
  const { vow: _v2, resolver: _r2 } = zone.makeOnce('v2', () => makeVowKit());
43
50
 
44
51
  const log = zone.makeOnce('log', () => makeLogStore());
45
- const bij = zone.makeOnce('bij', makeBijection);
46
-
47
- const mem = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
52
+ const bijection = zone.makeOnce('bij', makeBijection);
53
+
54
+ const mem = makeReplayMembrane({
55
+ log,
56
+ bijection,
57
+ vowTools,
58
+ watchWake,
59
+ panic,
60
+ });
48
61
 
49
62
  const p1 = mem.hostToGuest(v1);
50
63
  t.deepEqual(log.dump(), []);
@@ -85,7 +98,7 @@ const testReplay = async (t, zone) => {
85
98
  const log = /** @type {LogStore} */ (
86
99
  zone.makeOnce('log', () => Fail`need log`)
87
100
  );
88
- const bij = /** @type {Bijection} */ (
101
+ const bijection = /** @type {Bijection} */ (
89
102
  zone.makeOnce('bij', () => Fail`need bij`)
90
103
  );
91
104
 
@@ -97,7 +110,13 @@ const testReplay = async (t, zone) => {
97
110
  ['doFulfill', v1, 'x'],
98
111
  ]);
99
112
 
100
- const mem = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
113
+ const mem = makeReplayMembrane({
114
+ log,
115
+ bijection,
116
+ vowTools,
117
+ watchWake,
118
+ panic,
119
+ });
101
120
  t.true(log.isReplaying());
102
121
  t.is(log.getIndex(), 0);
103
122
 
@@ -17,6 +17,11 @@ import { prepareLogStore } from '../src/log-store.js';
17
17
  import { prepareBijection } from '../src/bijection.js';
18
18
  import { makeReplayMembrane } from '../src/replay-membrane.js';
19
19
 
20
+ /**
21
+ * @import {PromiseKit} from '@endo/promise-kit'
22
+ * @import {Zone} from '@agoric/base-zone'
23
+ */
24
+
20
25
  const watchWake = _vowish => {};
21
26
  const panic = problem => Fail`panic over ${problem}`;
22
27
 
@@ -31,14 +36,20 @@ const testMissingStop = async (t, zone) => {
31
36
  const makeBijection = prepareBijection(zone);
32
37
 
33
38
  const log = makeLogStore();
34
- const bij = makeBijection();
39
+ const bijection = makeBijection();
35
40
 
36
- const memA = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
41
+ const memA = makeReplayMembrane({
42
+ log,
43
+ bijection,
44
+ vowTools,
45
+ watchWake,
46
+ panic,
47
+ });
37
48
 
38
49
  const { vow: v1, resolver: r1 } = makeVowKit();
39
50
 
40
51
  const p1A = memA.hostToGuest(v1);
41
- t.true(bij.has(p1A, v1));
52
+ t.true(bijection.has(p1A, v1));
42
53
 
43
54
  await eventLoopIteration();
44
55
 
@@ -48,12 +59,18 @@ const testMissingStop = async (t, zone) => {
48
59
  // except stopping the old membrane,
49
60
  // to demonstate why `makeGuestForHostVow` also tests`stopped`.
50
61
  log.reset();
51
- bij.reset();
52
- const memB = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
62
+ bijection.reset();
63
+ const memB = makeReplayMembrane({
64
+ log,
65
+ bijection,
66
+ vowTools,
67
+ watchWake,
68
+ panic,
69
+ });
53
70
 
54
71
  const p1B = memB.hostToGuest(v1);
55
- t.true(bij.has(p1B, v1));
56
- t.false(bij.hasGuest(p1A));
72
+ t.true(bijection.has(p1B, v1));
73
+ t.false(bijection.hasGuest(p1A));
57
74
 
58
75
  await eventLoopIteration();
59
76
 
@@ -81,14 +98,20 @@ const testProperStop = async (t, zone) => {
81
98
  const makeBijection = prepareBijection(zone);
82
99
 
83
100
  const log = makeLogStore();
84
- const bij = makeBijection();
101
+ const bijection = makeBijection();
85
102
 
86
- const memA = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
103
+ const memA = makeReplayMembrane({
104
+ log,
105
+ bijection,
106
+ vowTools,
107
+ watchWake,
108
+ panic,
109
+ });
87
110
 
88
111
  const { vow: v1, resolver: r1 } = makeVowKit();
89
112
 
90
113
  const p1A = memA.hostToGuest(v1);
91
- t.true(bij.has(p1A, v1));
114
+ t.true(bijection.has(p1A, v1));
92
115
 
93
116
  await eventLoopIteration();
94
117
 
@@ -98,13 +121,19 @@ const testProperStop = async (t, zone) => {
98
121
  // including stopping the old membrane,
99
122
  // to demonstate why `makeGuestForHostVow` also tests`stopped`.
100
123
  log.reset();
101
- bij.reset();
124
+ bijection.reset();
102
125
  memA.stop(); // the point
103
- const memB = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
126
+ const memB = makeReplayMembrane({
127
+ log,
128
+ bijection,
129
+ vowTools,
130
+ watchWake,
131
+ panic,
132
+ });
104
133
 
105
134
  const p1B = memB.hostToGuest(v1);
106
- t.true(bij.has(p1B, v1));
107
- t.false(bij.hasGuest(p1A));
135
+ t.true(bijection.has(p1B, v1));
136
+ t.false(bijection.hasGuest(p1A));
108
137
 
109
138
  await eventLoopIteration();
110
139
 
@@ -18,6 +18,14 @@ import { prepareLogStore } from '../src/log-store.js';
18
18
  import { prepareBijection } from '../src/bijection.js';
19
19
  import { makeReplayMembrane } from '../src/replay-membrane.js';
20
20
 
21
+ /**
22
+ * @import {PromiseKit} from '@endo/promise-kit'
23
+ * @import {Zone} from '@agoric/base-zone'
24
+ * @import {MapStore} from '@agoric/store';
25
+ * @import {LogStore} from '../src/log-store.js';
26
+ * @import {Bijection} from '../src/bijection.js';
27
+ */
28
+
21
29
  const watchWake = _vowish => {};
22
30
  const panic = problem => Fail`panic over ${problem}`;
23
31
 
@@ -61,9 +69,15 @@ const testFirstPlay = async (t, zone, showOnConsole = false) => {
61
69
  const { vow: v2, resolver: r2 } = makeVowKit();
62
70
 
63
71
  const log = zone.makeOnce('log', () => makeLogStore());
64
- const bij = zone.makeOnce('bij', makeBijection);
65
-
66
- const mem = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
72
+ const bijection = zone.makeOnce('bij', makeBijection);
73
+
74
+ const mem = makeReplayMembrane({
75
+ log,
76
+ bijection,
77
+ vowTools,
78
+ watchWake,
79
+ panic,
80
+ });
67
81
 
68
82
  const g1 = mem.hostToGuest(v1);
69
83
  t.true(isPromise(g1));
@@ -71,9 +85,9 @@ const testFirstPlay = async (t, zone, showOnConsole = false) => {
71
85
  t.is(await g1, 'x');
72
86
 
73
87
  const hOrch7 = makeOrchestra(7, v2, r2);
74
- t.false(bij.hasHost(hOrch7));
88
+ t.false(bijection.hasHost(hOrch7));
75
89
  const gOrch7 = mem.hostToGuest(hOrch7);
76
- t.true(bij.has(gOrch7, hOrch7));
90
+ t.true(bijection.has(gOrch7, hOrch7));
77
91
 
78
92
  const prod = gOrch7.scale(3);
79
93
  t.is(prod, 21);
@@ -126,7 +140,7 @@ const testBadReplay = async (t, zone) => {
126
140
  const log = /** @type {LogStore} */ (
127
141
  zone.makeOnce('log', () => Fail`need log`)
128
142
  );
129
- const bij = /** @type {Bijection} */ (
143
+ const bijection = /** @type {Bijection} */ (
130
144
  zone.makeOnce('bij', () => Fail`need bij`)
131
145
  );
132
146
 
@@ -135,7 +149,7 @@ const testBadReplay = async (t, zone) => {
135
149
  const hOrch7 = dump[1][1];
136
150
  const hErr = dump[4][2];
137
151
 
138
- t.false(bij.hasHost(hOrch7));
152
+ t.false(bijection.hasHost(hOrch7));
139
153
 
140
154
  t.deepEqual(dump, [
141
155
  ['doFulfill', v1, 'x'],
@@ -145,13 +159,19 @@ const testBadReplay = async (t, zone) => {
145
159
  ['doThrow', 3, hErr],
146
160
  ]);
147
161
 
148
- const mem = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
162
+ const mem = makeReplayMembrane({
163
+ log,
164
+ bijection,
165
+ vowTools,
166
+ watchWake,
167
+ panic,
168
+ });
149
169
 
150
170
  const g1 = mem.hostToGuest(v1);
151
171
  mem.wake();
152
172
  t.is(await g1, 'x');
153
173
  const gOrch7 = mem.hostToGuest(hOrch7);
154
- t.true(bij.has(gOrch7, hOrch7));
174
+ t.true(bijection.has(gOrch7, hOrch7));
155
175
 
156
176
  // failure of guest to reproduce behavior from previous incarnations
157
177
  t.throws(() => gOrch7.scale(4), {
@@ -172,7 +192,7 @@ const testGoodReplay = async (t, zone) => {
172
192
  const log = /** @type {LogStore} */ (
173
193
  zone.makeOnce('log', () => Fail`need log`)
174
194
  );
175
- const bij = /** @type {Bijection} */ (
195
+ const bijection = /** @type {Bijection} */ (
176
196
  zone.makeOnce('bij', () => Fail`need bij`)
177
197
  );
178
198
 
@@ -181,7 +201,7 @@ const testGoodReplay = async (t, zone) => {
181
201
  const hOrch7 = dump[1][1];
182
202
  const hErr = dump[4][2];
183
203
 
184
- t.false(bij.hasHost(hOrch7));
204
+ t.false(bijection.hasHost(hOrch7));
185
205
 
186
206
  t.deepEqual(dump, [
187
207
  ['doFulfill', v1, 'x'],
@@ -193,13 +213,19 @@ const testGoodReplay = async (t, zone) => {
193
213
 
194
214
  const oldLogLen = dump.length;
195
215
 
196
- const mem = makeReplayMembrane(log, bij, vowTools, watchWake, panic);
216
+ const mem = makeReplayMembrane({
217
+ log,
218
+ bijection,
219
+ vowTools,
220
+ watchWake,
221
+ panic,
222
+ });
197
223
 
198
224
  const g1 = mem.hostToGuest(v1);
199
225
  mem.wake();
200
226
  t.is(await g1, 'x');
201
227
  const gOrch7 = mem.hostToGuest(hOrch7);
202
- t.true(bij.has(gOrch7, hOrch7));
228
+ t.true(bijection.has(gOrch7, hOrch7));
203
229
 
204
230
  // replay
205
231
  const prodA = gOrch7.scale(3);
@@ -0,0 +1,73 @@
1
+ import { expectType } from 'tsd';
2
+ import type { Vow, VowTools } from '@agoric/vow';
3
+ import type {
4
+ HostOf,
5
+ GuestOf,
6
+ HostInterface,
7
+ GuestInterface,
8
+ } from '../src/types.js';
9
+
10
+ const castable: unknown = null;
11
+ const vt: VowTools = null as any;
12
+
13
+ const sumVow = (a: number, b: number) => vt.asVow(() => a + b);
14
+
15
+ const sumPromise = (a: number, b: number) => Promise.resolve(a + b);
16
+
17
+ expectType<(p1: number, p2: number) => Promise<number>>(
18
+ castable as GuestOf<typeof sumVow>,
19
+ );
20
+
21
+ expectType<(p1: number, p2: number) => Vow<number>>(
22
+ castable as HostOf<typeof sumPromise>,
23
+ );
24
+ expectType<(p1: number, p2: number) => Vow<void>>(
25
+ // @ts-expect-error incompatible return type
26
+ castable as HostOf<typeof sumPromise>,
27
+ );
28
+
29
+ // Test HostInterface and GuestInterface with an exoClass object
30
+ type ExoAPIBase = {
31
+ getValue: () => number;
32
+ setValue: (value: number) => void;
33
+ getCopyData: () => Record<string, number>[];
34
+ // TODO include `getRemote() => Guarded<...>`, since durable exos are passable
35
+ };
36
+ type ExoGuestAPI = ExoAPIBase & {
37
+ getValueAsync: () => Promise<number>;
38
+ };
39
+
40
+ type ExoHostAPI = ExoAPIBase & {
41
+ getValueAsync: () => Vow<number>;
42
+ };
43
+
44
+ expectType<
45
+ ExoAPIBase & {
46
+ getValueAsync: () => Vow<number>;
47
+ }
48
+ >(castable as HostInterface<ExoGuestAPI>);
49
+ expectType<
50
+ ExoAPIBase & {
51
+ getValueAsync: () => Promise<number>;
52
+ }
53
+ >(castable as GuestInterface<ExoHostAPI>);
54
+
55
+ // Test HostInterface and GuestInterface with classKit (nested) objects
56
+ expectType<{
57
+ facet: ExoAPIBase & {
58
+ getValueAsync: () => Vow<number>;
59
+ };
60
+ }>(
61
+ castable as HostInterface<{
62
+ facet: ExoGuestAPI;
63
+ }>,
64
+ );
65
+ expectType<{
66
+ facet: ExoAPIBase & {
67
+ getValueAsync: () => Promise<number>;
68
+ };
69
+ }>(
70
+ castable as GuestInterface<{
71
+ facet: ExoHostAPI;
72
+ }>,
73
+ );
package/tsconfig.json CHANGED
@@ -9,5 +9,7 @@
9
9
  "scripts",
10
10
  "src/**/*.js",
11
11
  "test/**/*.js",
12
+ "src/**/*.ts",
13
+ "test/**/*.ts",
12
14
  ],
13
15
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"iBAWa,SAAS,GACrB,UAAsB,GACtB,WAAuB,GACvB,QAAoB,GACpB,MAAkB;WAMN,CAAC,gCAAD,CAAC;UAKD,CAAC,gCAAD,CAAC;;;;;aAQQ,CAAC;;;sBAIV,CAAC,GAAG,cAAc,EAAE,KAAK,EAAE,KAAK,KAAK,cAAS;4BAI9C,CAAC,GAAG,cAAc,EAAE,IAAI,EAAE,KAAK,OAAO;;;2FA7BlC,CAAC;;;wBAyBN,SAAQ;;;;;;;;;;;;;;;;;;;;;;;;mBAeP,QAAQ,GAAC,OAAO;eAIhB;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAC,GAC7B;IAAC,IAAI,EAAE,OAAO,CAAC;IAAE,OAAO,EAAE,GAAG,CAAA;CAAC;cAStB,CAAC,4BADK,CAAC;SAAd,CAAC,IAAI,EACE,CAAC,AADA,KAAK,CAAC;cACd,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI;;;;;;;gBAQlB,CAAE,iEAAiE;AAC/E,EAAQ,EAAE,WAAW,EACrB,GAAS,EAAE,OAAO,EAClB,WAAiB,EAAE,IAAI,CAClB,GAAG,CACR,EAAQ,EAAE,UAAU,EACpB,GAAS,EAAE,OAAO,EAClB,MAAY,EAAE,IAAI,CACb,GAAG,CACR,EAAQ,EAAE,UAAU,EACpB,SAAe,EAAE,MAAM,EACvB,MAAY,EAAE,IAAI,CACb,GAAG,CACR,EAAQ,EAAE,SAAS,EACnB,SAAe,EAAE,MAAM,EACvB,OAAa,EAAE,IAAI,CACd,GAAG,CAAE,qEAAqE;AAC/E,EAAQ,EAAE,WAAW,EACrB,MAAY,EAAE,IAAI,EAClB,OAAa,EAAE,WAAW,GAAC,SAAS,EACpC,IAAU,EAAE,IAAI,EAAE,EAClB,SAAe,EAAE,MAAM,CAClB;gCAhGuB,mBAAmB;8BACrB,kBAAkB;0BACtB,mBAAmB;yBACV,aAAa;8BAAb,aAAa;8BAClB,gBAAgB;+BACf,gBAAgB;oCACX,sBAAsB"}