Skip to content

Commit

Permalink
test(types): add types test
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 28, 2022
1 parent c2b5356 commit e80410e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/casting/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"include": [
"*.js",
"public/**/*.js",
"src/**/*.js",
"test/**/*.js",
"src",
"test",
],
}
2 changes: 0 additions & 2 deletions packages/casting/src/types.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Make this a module.
import '@agoric/notifier';

export {};

/** @template T @typedef {import('@endo/far').ERef<T>} ERef */
Expand Down
30 changes: 30 additions & 0 deletions packages/casting/test/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { E } from '@endo/far';
import { expectType } from 'tsd';
import type { ValueFollower } from '../src/follower-cosmjs.js';
import { makeFollower } from '../src/follower.js';
import { iterateLatest } from '../src/iterable.js';
import { makeLeader } from '../src/leader-netconfig.js';
import type { ValueFollowerElement } from '../src/types.js';

type ThePublishedDatum = { a: 1; b: 'two' };
type TheFollowerElement = ValueFollowerElement<ThePublishedDatum>;

const leader = makeLeader();

{
const f = makeFollower<ThePublishedDatum>('', leader, {});
expectType<ValueFollower<ThePublishedDatum>>(await f);

expectType<AsyncIterable<TheFollowerElement>>(await E(f).getLatestIterable());

expectType<AsyncIterable<TheFollowerElement>>(await E(f).getLatestIterable());

expectType<AsyncIterable<TheFollowerElement>>(
await E(f).getReverseIterable(),
);

const iter = iterateLatest(f);
for await (const { value } of iter) {
expectType<ThePublishedDatum>(value);
}
}

0 comments on commit e80410e

Please sign in to comment.