Merged
Conversation
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).
Member
|
Makes sense. At some point we should improve the types here so that the table is more strictly typed (we did a pretty good job with having strict types in the arrow js library). |
domoritz
approved these changes
Jun 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the TypeScript definition:
setting
TNexttonullcan cause a typing error whenstrictNullChecksis enabled. For example:(from uwdata/mosaic#792 (comment))
While the strict type for
TNextshould technically beundefined, since this generator function does not make use of the value passed to.next(), it's more flexible to keep it asany. 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).