adaltas / adaltas/node-csv

Options type declaration is missing underlying stream properties

Open
#283 0 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.