Skip to content

Commit 43e4d43

Browse files
committed
refactor(far): deduplicate types from eventual-send by aliasing
1 parent b8c2107 commit 43e4d43

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

packages/eventual-send/src/E.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ export default makeE;
254254
/** @typedef {ReturnType<makeE>} EProxy */
255255

256256
/**
257-
* Creates a type that accepts both near and marshalled references that were
258-
* returned from `Remotable` or `Far`, and also promises for such references.
257+
* Declare an object that is potentially a far reference of type Primary whose
258+
* auxilliary data has type Local. This should be used only for consumers of
259+
* Far objects in arguments and declarations; the only creators of Far objects
260+
* are distributed object creator components like the `Far` or `Remotable`
261+
* functions.
259262
*
260263
* @template Primary The type of the primary reference.
261264
* @template [Local=DataOnly<Primary>] The local properties of the object.
@@ -274,6 +277,9 @@ export default makeE;
274277
* @see {@link https://github.com/microsoft/TypeScript/issues/31394}
275278
* @template T
276279
* @typedef {PromiseLike<T> | T} ERef
280+
* Declare that `T` may or may not be a Promise. This should be used only for
281+
* consumers of arguments and declarations; return values should specifically be
282+
* `Promise<T>` or `T` itself.
277283
*/
278284

279285
/**
@@ -406,8 +412,9 @@ export default makeE;
406412
*/
407413

408414
/**
409-
* Type for an object that must only be invoked with E. It supports a given
410-
* interface but declares all the functions as asyncable.
415+
* Declare a near object that must only be invoked with E, even locally. It
416+
* supports the `T` interface but additionally permits `T`'s methods to return
417+
* `PromiseLike`s even if `T` declares them as only synchronous.
411418
*
412419
* @template T
413420
* @typedef {(

packages/far/src/exports.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { FarRef, ERef, EOnly, EReturn } from '@endo/eventual-send';

packages/far/src/exports.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Just a dummy to use exports.d.ts and satisfy runtime imports.
2+
export {};

packages/far/src/index.js

+2-27
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
export { E } from '@endo/eventual-send';
22
export { Far, getInterfaceOf, passStyleOf } from '@endo/pass-style';
33

4-
// TODO re-export from eventual-send, may require .d.ts
5-
/**
6-
* @template Primary
7-
* @template [Local=import('@endo/eventual-send').DataOnly<Primary>]
8-
* @typedef {import('@endo/eventual-send').FarRef<Primary, Local>} FarRef
9-
* Declare an object that is potentially a far reference of type Primary whose
10-
* auxilliary data has type Local. This should be used only for consumers of
11-
* Far objects in arguments and declarations; the only creators of Far objects
12-
* are distributed object creator components like the `Far` or `Remotable`
13-
* functions.
14-
*/
15-
16-
/**
17-
* @template T
18-
* @typedef {import('@endo/eventual-send').ERef<T>} ERef
19-
* Declare that `T` may or may not be a Promise. This should be used only for
20-
* consumers of arguments and declarations; return values should specifically be
21-
* `Promise<T>` or `T` itself.
22-
*/
23-
24-
/**
25-
* @template T
26-
* @typedef {import('@endo/eventual-send').EOnly<T>} EOnly
27-
* Declare a near object that must only be invoked with E, even locally. It
28-
* supports the `T` interface but additionally permits `T`'s methods to return
29-
* `PromiseLike`s even if `T` declares them as only synchronous.
30-
*/
4+
// eslint-disable-next-line import/export
5+
export * from './exports.js';

0 commit comments

Comments
 (0)