TypeScript error on Type 'ResultSet' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.

Description

Hi,

Really love the driver, great to see it evolving.

We're using TypeScript (3.8.3) for our projects and tsc is complaining about the asynciterator.

The example code from https://docs.datastax.com/en/developer/nodejs-driver/4.5/features/paging/ doesn't compile.

{{const result = await client.execute(query, params, { prepare: true });

for await (const row of result) {
console.log(row[columnName]);
}
}}

gives

{{error TS2504: Type 'ResultSet' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.

52 for await (const row of result) {
~~~~~~

Found 1 error.}}

{{$ npx tsc --version
Version 3.8.3
}}

Environment

None

Pull Requests

None

Activity

Show:
Jorge Bay Gondra
May 28, 2020, 8:07 AM

oh, good findings!

yes, its missing the async iterator in the definition: https://github.com/datastax/nodejs-driver/blob/v4.5.2/lib/types/index.d.ts#L322-L342

Roland van der Heijden
May 28, 2020, 1:17 PM

Great! I ‘fixed’ the issue short term by making the result const of type any, but that’s not what we use TS for

Assignee

Jorge Bay Gondra

Reporter

Roland van der Heijden

Reviewer

None

Fix versions

Labels

None

Components

None

PM Priority

None

Reproduced in

None

Affects versions

Priority

Major
Configure