From b1ca13bb472d4b450f2494ac7676dd7a9d96319a Mon Sep 17 00:00:00 2001 From: hjf Date: Mon, 4 Aug 2025 14:49:25 -0300 Subject: [PATCH] fix: onRecord accepts a different return type --- packages/csv-parse/lib/index.d.ts | 6 +++--- packages/csv-parse/lib/sync.d.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/csv-parse/lib/index.d.ts b/packages/csv-parse/lib/index.d.ts index 898f74b6..4b6f2522 100644 --- a/packages/csv-parse/lib/index.d.ts +++ b/packages/csv-parse/lib/index.d.ts @@ -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 { +export interface Options { /** * If true, the parser will attempt to convert read data types to native types. * @deprecated Use {@link cast} @@ -366,8 +366,8 @@ export interface Options { /** * 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. diff --git a/packages/csv-parse/lib/sync.d.ts b/packages/csv-parse/lib/sync.d.ts index 4686a61b..057b735d 100644 --- a/packages/csv-parse/lib/sync.d.ts +++ b/packages/csv-parse/lib/sync.d.ts @@ -1,13 +1,13 @@ import { Options } from "./index.js"; -type OptionsWithColumns = Omit, "columns"> & { +type OptionsWithColumns = Omit, "columns"> & { columns: Exclude; }; -declare function parse( +declare function parse( input: Buffer | string | Uint8Array, - options: OptionsWithColumns, -): T[]; + options: OptionsWithColumns, +): U[]; declare function parse( input: Buffer | string | Uint8Array, options: Options,