Skip to content

Commit 7269bc5

Browse files
committed
fix(parser): remove 'as any' casting per review feedback
- Replace 'as any' with proper TypeScript types in test files - Use APIGatewayProxyEvent type for API Gateway tests - Use APIGatewayProxyEventV2 type for API Gateway v2 tests - Import types from '../../../src/types/schema.js' This addresses code review feedback for better type safety
1 parent 9bdf124 commit 7269bc5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/parser/tests/unit/schema/apigw.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
APIGatewayRequestAuthorizerEventSchema,
55
APIGatewayTokenAuthorizerEventSchema,
66
} from '../../../src/schemas/index.js';
7+
import type { APIGatewayProxyEvent } from '../../../src/types/schema.js';
78
import { getTestEvent } from '../helpers/utils.js';
89

910
describe('Schema: API Gateway REST', () => {
@@ -100,10 +101,10 @@ describe('Schema: API Gateway REST', () => {
100101
});
101102
it('parses an event with IPv6 sourceIp', () => {
102103
// Prepare
103-
const event = getTestEvent({
104+
const event = getTestEvent<APIGatewayProxyEvent>({
104105
eventsPath,
105106
filename: 'no-auth',
106-
}) as any;
107+
});
107108
// Add IPv6 address to the event
108109
event.requestContext.identity.sourceIp =
109110
'2001:0db8:85a3:0000:0000:8a2e:0370:7334';
@@ -119,10 +120,10 @@ describe('Schema: API Gateway REST', () => {
119120

120121
it('parses an event with shortened IPv6 sourceIp', () => {
121122
// Prepare
122-
const event = getTestEvent({
123+
const event = getTestEvent<APIGatewayProxyEvent>({
123124
eventsPath,
124125
filename: 'no-auth',
125-
}) as any;
126+
});
126127
// Add shortened IPv6 address to the event
127128
event.requestContext.identity.sourceIp = '::1';
128129

packages/parser/tests/unit/schema/apigwv2.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ describe('Schema: API Gateway HTTP (v2)', () => {
4747

4848
it('parses an event with IPv6 sourceIp', () => {
4949
// Prepare
50-
const event = getTestEvent({
50+
const event = getTestEvent<APIGatewayProxyEventV2>({
5151
eventsPath,
5252
filename: 'no-auth',
53-
}) as any;
53+
});
5454
// Add IPv6 address to the event
5555
event.requestContext.http.sourceIp =
5656
'2001:0db8:85a3:0000:0000:8a2e:0370:7334';
@@ -66,10 +66,10 @@ describe('Schema: API Gateway HTTP (v2)', () => {
6666

6767
it('parses an event with shortened IPv6 sourceIp', () => {
6868
// Prepare
69-
const event = getTestEvent({
69+
const event = getTestEvent<APIGatewayProxyEventV2>({
7070
eventsPath,
7171
filename: 'no-auth',
72-
}) as any;
72+
});
7373
// Add shortened IPv6 address to the event
7474
event.requestContext.http.sourceIp = '::1';
7575

0 commit comments

Comments
 (0)