Skip to content

Commit 04790b2

Browse files
committed
Refine return types
1 parent 40eeab5 commit 04790b2

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

crates/bindings-typescript/src/lib/indexes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export interface ReadonlyRangedIndex<
108108
> {
109109
filter(
110110
range: IndexScanRangeBounds<TableDef, I>
111-
): IteratorObject<Prettify<RowType<TableDef>>>;
111+
): IteratorObject<Prettify<RowType<TableDef>>, undefined>;
112112
}
113113

114114
/**

crates/bindings-typescript/src/lib/table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ export interface ReadonlyTableMethods<TableDef extends UntypedTableDef> {
166166
count(): bigint;
167167

168168
/** Iterate over all rows in the TX state. Rust Iterator<Item=Row> → TS IterableIterator<Row>. */
169-
iter(): IteratorObject<Prettify<RowType<TableDef>>>;
170-
[Symbol.iterator](): IteratorObject<Prettify<RowType<TableDef>>>;
169+
iter(): IteratorObject<Prettify<RowType<TableDef>>, undefined>;
170+
[Symbol.iterator](): IteratorObject<Prettify<RowType<TableDef>>, undefined>;
171171
}
172172

173173
/**

crates/bindings-typescript/src/sdk/table_cache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class TableCacheImpl<
201201
return impl as ReadonlyIndex<TableDef, I>;
202202
} else {
203203
const impl: ReadonlyRangedIndex<TableDef, I> = {
204-
*filter(range: any): IteratorObject<Row, void> {
204+
*filter(range: any): IteratorObject<Row, undefined> {
205205
for (const row of self.iter()) {
206206
if (matchRange(row, range)) yield row;
207207
}
@@ -223,7 +223,7 @@ export class TableCacheImpl<
223223
*/
224224
iter(): IteratorObject<
225225
Prettify<RowType<TableDefForTableName<RemoteModule, TableName>>>,
226-
void
226+
undefined
227227
> {
228228
function* generator(
229229
rows: Map<
@@ -232,7 +232,7 @@ export class TableCacheImpl<
232232
>
233233
): IteratorObject<
234234
Prettify<RowType<TableDefForTableName<RemoteModule, TableName>>>,
235-
void
235+
undefined
236236
> {
237237
for (const [row] of rows.values()) {
238238
yield row as Prettify<
@@ -249,7 +249,7 @@ export class TableCacheImpl<
249249
*/
250250
[Symbol.iterator](): IteratorObject<
251251
Prettify<RowType<TableDefForTableName<RemoteModule, TableName>>>,
252-
void
252+
undefined
253253
> {
254254
return this.iter();
255255
}

crates/bindings-typescript/src/server/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ function hasOwn<K extends PropertyKey>(
649649
return Object.hasOwn(o, k);
650650
}
651651

652-
function* tableIterator(id: u32, ty: AlgebraicType): Generator<any, void> {
652+
function* tableIterator(id: u32, ty: AlgebraicType): Generator<any, undefined> {
653653
using iter = new IteratorHandle(id);
654654
const { typespace } = MODULE_DEF;
655655

crates/bindings-typescript/src/server/view.test-d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ spacetime.anonymousView(
8787
spacetime.anonymousView(
8888
{ name: 'optionalPersonWrong', public: true },
8989
optionalPerson,
90+
// @ts-expect-error returns a value of the wrong type.
9091
ctx => {
9192
return ctx.db.order.iter().next().value;
9293
}

0 commit comments

Comments
 (0)