workers-types icon indicating copy to clipboard operation
workers-types copied to clipboard

`D1PreparedStatement.all`'s return type is wrong?

Open sizumita opened this issue 2 years ago • 1 comments

https://github.com/cloudflare/workers-types/blob/master/src/workers.json#L1712-L1721 It's return type is Promise<D1Result<T[]>>. I expect that D1Result<T[]>.results returns T[][] but actually it returns T[].

So, I think D1PreparedStatement.all's return type should be Promise<D1Result<T>>.

sizumita avatar Sep 09 '22 23:09 sizumita

The docs also say that errors are thrown and never mention the error property. So I wonder if the error property can actually exist, and consequently if results is optional.

D1PreparedStatement.run() also has a results? property, even though the docs say that .run() returns no results (same goes for exec I think)

probablykasper avatar Sep 18 '22 20:09 probablykasper

Fixed by https://github.com/cloudflare/workers-types/pull/285.

mrbbot avatar Oct 06 '22 09:10 mrbbot

Opened #289 for the other issues I mentioned

probablykasper avatar Oct 07 '22 16:10 probablykasper