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;
Summary
I am using
csv-parsein a TypeScript project the following way:In my TS code the
recordsare of type any becauseparsehas the following type definiton:sync.d.cts
Could the
parsefunction accept a type argument to define the type its output? I am thinking of something like this: