workerd
workerd copied to clipboard
SqlStorageCursor.next type is not OK
https://github.com/cloudflare/workerd/blob/d7e9c38f6af8b6587ab23fd9c4635af522273ff1/src/workerd/api/sql.h#L212
Description
In this piece of code
let cursor = this.sql.exec(`SELECT seatId, occupant FROM seats`);
// Cursors are iterable.
let results = Iterator.from(cursor).map((row) => {
// Each row is an object with a property for each column.
return { seatNumber: row.seatId, occupant: row.occupant };
}).toArray();
row from map shows to may be undefined, but it shouldn't be
My solution
replace
next(): { done?: false, value: T } | { done: true, value?: never };
with
next(): IteratorResult<T, undefined>;
This looks like a correct change, right @jasnell ?
also experiencing this issue and the change seems to work. TS Playground with minimal repro