Options type declaration is missing underlying stream properties
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4.3k
- Forks
- 299
- Avg merge
- 16h 19m
- Merged PRs (30d)
- 1
Description
Describe the bug
csv-parse and csv-stringify (possibly others too) have Options class defined, which does not extend corresponding Stream options.
To Reproduce
import * as csvParse from 'csv-parse';
const csvReader = csvParse({ highWaterMark: 65 * 1024 });
Will produce a type error, because highWaterMark is not defined on parse.Options, but if compiled (ignoring the error) the code works as expected.
Additional context
The Options interface should extend DuplexOptions interface. But encoding property is defined in both and is not compatible, so may need to be omitted from one of the types.
The following d.ts definition file can be use as a workaround:
import { DuplexOptions } from 'stream';
declare module 'csv-stringify' {
interface Options extends Omit<DuplexOptions, 'encoding'> {}
}
declare module 'csv-parse' {
interface Options extends Omit<DuplexOptions, 'encoding'> {}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the parse and stringify Options declarations and inspect how their encoding properties relate to Node's DuplexOptions. Use the highWaterMark example and the provided module-augmentation workaround as the starting checks. Done means the declarations accept underlying stream properties without introducing an incompatible encoding type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100