From e614240a87959e42a7594ffef77d2174a9ae8642 Mon Sep 17 00:00:00 2001 From: Kevin De Porre Date: Mon, 24 Jun 2024 12:14:27 +0200 Subject: [PATCH] Improve type signature of encodeRow and encodeRows --- clients/typescript/src/client/conversions/converter.ts | 9 +++++---- clients/typescript/src/client/model/transforms.ts | 9 +++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/clients/typescript/src/client/conversions/converter.ts b/clients/typescript/src/client/conversions/converter.ts index 2197210c55..e0759a1584 100644 --- a/clients/typescript/src/client/conversions/converter.ts +++ b/clients/typescript/src/client/conversions/converter.ts @@ -1,3 +1,4 @@ +import { Row } from '../../util' import { AnyTableSchema } from '../model' import { PgType } from './types' @@ -13,19 +14,19 @@ export interface Converter { * @param row The row to encode * @param tableSchema The schema of the table for this row. */ - encodeRow = Record>( + encodeRow( row: Record, tableSchema: Pick - ): T + ): Row /** * Encodes the provided rows for storing in the database. * @param rows The rows to encode * @param tableSchema The schema of the table for these rows. */ - encodeRows = Record>( + encodeRows( rows: Array>, tableSchema: Pick - ): Array + ): Array /** * Decodes the provided value from the database. * @param v The value to decode. diff --git a/clients/typescript/src/client/model/transforms.ts b/clients/typescript/src/client/model/transforms.ts index 35d85297b4..a58fdd036b 100644 --- a/clients/typescript/src/client/model/transforms.ts +++ b/clients/typescript/src/client/model/transforms.ts @@ -95,12 +95,9 @@ export function transformTableRecord( schema !== undefined ? validate(transformedParsedRow, schema) : transformedParsedRow - const transformedRecord = converter.encodeRow( - validatedTransformedParsedRow, - { - fields, - } - ) + const transformedRecord = converter.encodeRow(validatedTransformedParsedRow, { + fields, + }) // check if any of the immutable fields were modified const validatedTransformedRecord = validateRecordTransformation(