Skip to content

Commit 4b7f8ab

Browse files
committed
Changed the RuntimeZodType from any to unknown
1 parent e1a2ea9 commit 4b7f8ab

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/batch/src/parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
*
1414
* @param schema - The schema to check
1515
*/
16-
const isZodSchema = (schema: StandardSchemaV1): schema is RuntimeZodType =>
16+
const isZodSchema = (schema: StandardSchemaV1) =>
1717
schema['~standard'].vendor === SchemaVendor.Zod;
1818

1919
/**
@@ -40,20 +40,23 @@ const createExtendedSchema = async (options: {
4040
const { JSONStringified } = await import(
4141
'@aws-lambda-powertools/parser/helpers'
4242
);
43+
// @ts-expect-error - we know it's a Zod schema due to the runtime check earlier
4344
schema = JSONStringified(innerSchema);
4445
break;
4546
}
4647
case 'base64': {
4748
const { Base64Encoded } = await import(
4849
'@aws-lambda-powertools/parser/helpers'
4950
);
51+
// @ts-expect-error - we know it's a Zod schema due to the runtime check earlier
5052
schema = Base64Encoded(innerSchema);
5153
break;
5254
}
5355
case 'unmarshall': {
5456
const { DynamoDBMarshalled } = await import(
5557
'@aws-lambda-powertools/parser/helpers/dynamodb'
5658
);
59+
// @ts-expect-error - we know it's a Zod schema due to the runtime check earlier
5760
schema = DynamoDBMarshalled(innerSchema);
5861
break;
5962
}

packages/batch/src/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,11 @@ type ParsedRecord<TRecord, TPayload, TOldPayload = TPayload> = TRecord extends {
248248
* Parts of the parser integration within BatchProcessor rely on Zod for schema transformations,
249249
* however some other parts also support other Standard Schema-compatible libraries.
250250
*
251-
* To avoid forcing a direct dependency on Zod, we use `any` here, which is not ideal but necessary.
251+
* To avoid forcing a direct dependency on Zod, we use `unknown` here, which is not ideal but necessary.
252252
*
253253
* The vendor is checked at runtime to ensure Zod is being used when required using `StandardSchemaV1['~standard'].vendor`.
254-
*
255-
* biome-ignore lint/suspicious/noExplicitAny: using `any` to avoid direct dependency on 'zod'
256254
*/
257-
type RuntimeZodType = any;
255+
type RuntimeZodType = unknown;
258256

259257
export type {
260258
BatchProcessingOptions,

0 commit comments

Comments
 (0)