Skip to content

Commit 95b2bb8

Browse files
kwonohjheer
authored andcommitted
Fix Generator type
In the TypeScript definition: ``` interface Generator<T = unknown, TReturn = any, TNext = any> ``` setting `TNext` to `null` can cause a typing error when `strictNullChecks` is enabled. For example: ``` error TS2763: Cannot iterate value because the 'next' method of its iterator expects type 'null', but for-of will always send 'undefined'. 288 for (const d of data) { ~~~~ ``` (from uwdata/mosaic#792 (comment)) While the strict type for `TNext` should technically be `undefined`, since this generator function does not make use of the value passed to `.next()`, it's more flexible to keep it as `any`. This is the default type and helps avoid blocking compatibility with libraries that may pass a value to `.next()` (even if that value is unused in this generator).
1 parent 1584777 commit 95b2bb8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class Table {
155155

156156
/**
157157
* Return an iterator over objects representing the rows of this table.
158-
* @returns {Generator<Record<string, any>, any, null>}
158+
* @returns {Generator<Record<string, any>, any, any>}
159159
*/
160160
*[Symbol.iterator]() {
161161
const { children, getFactory } = this;

0 commit comments

Comments
 (0)