fix(csv-parse): accept stream options in TypeScript - #514
Merged
Merged
Conversation
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.
parse({ highWaterMark: 16 })works at runtime but is rejected by TypeScript becauseOptionsdoes not include Node's stream settings. The same problem affects separate readable/writable buffer limits and theParserconstructor.Include
TransformOptionswhile keeping the parser's existingencodingtype, which also acceptsnullandfalse. 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: nullorfalse. 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.