Skip to content

fix(csv-parse): accept stream options in TypeScript - #514

Merged
wdavidw merged 3 commits into
adaltas:masterfrom
x0Lazarus:fix/parse-stream-option-types
Sep 30, 2026
Merged

wdavidw merged 3 commits into
adaltas:masterfrom
x0Lazarus:fix/parse-stream-option-types

Conversation

@x0Lazarus

Copy link
Copy Markdown
Contributor

parse({ highWaterMark: 16 }) works at runtime but is rejected by TypeScript because Options does not include Node's stream settings. The same problem affects separate readable/writable buffer limits and the Parser constructor.

Include TransformOptions while keeping the parser's existing encoding type, which also accepts null and false. Update the generated CommonJS and browser declarations to match. PR #301 added stream options to Stringify; this fills the remaining gap in Parse.

Tests cover constructor buffer settings, callback parsing and Buffer output with encoding: null or false. They fail type-checking against the original declarations. TypeScript passes with the fix, and all 53 API type/runtime tests pass on Node 20.20.2, 22.23.3 and 24.13.1. Packed-package ESM, CommonJS and browser type checks also pass, including checks that invalid option values are still rejected.

On Windows, the broader parser suite passes 546 tests with three existing tests pending; the sample loader is excluded because its file-URL handling fails on Windows. Tests were invoked directly through Mocha because the existing npm script's single-quoted glob also fails in cmd.exe. ESLint passes for the source declaration and tests. Other operating systems and browser runtime execution were not tested.

Fixes #283.

@wdavidw
wdavidw merged commit 218d35a into adaltas:master Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Options type declaration is missing underlying stream properties

2 participants