Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/csv-parse/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ Note, could not `extends stream.TransformOptions` because encoding can be
BufferEncoding and undefined as well as null which is not defined in the
extended type.
*/
export interface Options<T = string[]> {
export interface Options<T = string[], U = T> {
/**
* If true, the parser will attempt to convert read data types to native types.
* @deprecated Use {@link cast}
Expand Down Expand Up @@ -366,8 +366,8 @@ export interface Options<T = string[]> {
/**
* Alter and filter records by executing a user defined function.
*/
on_record?: (record: T, context: InfoRecord) => T | null | undefined;
onRecord?: (record: T, context: InfoRecord) => T | null | undefined;
on_record?: (record: T, context: InfoRecord) => U | null | undefined;
onRecord?: (record: T, context: InfoRecord) => U | null | undefined;
/**
* Function called when an error occured if the `skip_records_with_error`
* option is activated.
Expand Down
8 changes: 4 additions & 4 deletions packages/csv-parse/lib/sync.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Options } from "./index.js";

type OptionsWithColumns<T> = Omit<Options<T>, "columns"> & {
type OptionsWithColumns<T, U> = Omit<Options<T>, "columns"> & {
columns: Exclude<Options["columns"], undefined | false>;
};

declare function parse<T = unknown>(
declare function parse<T = unknown, U = T>(
input: Buffer | string | Uint8Array,
options: OptionsWithColumns<T>,
): T[];
options: OptionsWithColumns<T, U>,
): U[];
declare function parse(
input: Buffer | string | Uint8Array,
options: Options,
Expand Down