Skip to content

Function parse returns "any" - Could it be made generic? #407

@bennycode

Description

@bennycode

Summary

I am using csv-parse in a TypeScript project the following way:

import {parse} from 'csv-parse/sync';

const records = parse(input, {
  columns: true,
  delimiter: ',',
  skip_empty_lines: true
});

In my TS code the records are of type any because parse has the following type definiton:

sync.d.cts

declare function parse(input: Buffer | string, options?: Options): any;

Could the parse function accept a type argument to define the type its output? I am thinking of something like this:

declare function parse<T>(input: Buffer | string, options?: Options): T;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions