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 May 30, 2024
1 parent c55cd78 commit bfb7cdc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions packages/casting/test/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable */
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) {
assert(value, 'value undefined');
expectType<ThePublishedDatum>(value);
}
}
4 changes: 2 additions & 2 deletions packages/casting/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"include": [
"*.js",
"public/**/*.js",
"src/**/*.js",
"test/**/*.js",
"src",
"test",
],
}

0 comments on commit bfb7cdc

Please sign in to comment.