From dd58f463b0d7da1a2258e27a7998f9826616e0af Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:08:06 +0000 Subject: [PATCH] test: fix TypeScript errors in endpoints-integration.spec.ts --- tests/endpoints-2.0/endpoints-integration.spec.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/endpoints-2.0/endpoints-integration.spec.ts b/tests/endpoints-2.0/endpoints-integration.spec.ts index 1f043ae03e643..1b5c77411e380 100644 --- a/tests/endpoints-2.0/endpoints-integration.spec.ts +++ b/tests/endpoints-2.0/endpoints-integration.spec.ts @@ -19,9 +19,9 @@ describe("client list", () => { for (const client of clientList) { const serviceName = client.slice(7); - let defaultEndpointResolver; - let namespace; - let model; + let defaultEndpointResolver: any; + let namespace: any; + let model: any; // this may also work with dynamic async import() in a beforeAll() block, // but needs more effort than using synchronous require(). @@ -41,7 +41,9 @@ for (const client of clientList) { describe(`client-${serviceName} endpoint test cases`, () => { if (defaultEndpointResolver && namespace && model) { - const [, service] = Object.entries(model.shapes).find(([k, v]) => v?.["type"] === "service") as any; + const [, service] = Object.entries(model.shapes).find( + ([k, v]) => typeof v === "object" && v !== null && "type" in v && v.type === "service" + ) as any; const [, tests] = Object.entries(service.traits).find(([k, v]) => k === "smithy.rules#endpointTests") as any; if (tests?.testCases) { runTestCases(tests, service, defaultEndpointResolver, ""); @@ -106,8 +108,8 @@ async function runTestCase( } if (isErrorExpectation(expectation)) { const { error } = expectation; - const pass = (err) => err; - const normalizeQuotes = (s) => s.replace(/`/g, ""); + const pass = (err: any) => err; + const normalizeQuotes = (s: string) => s.replace(/`/g, ""); if (operationInputs) { for (const operationInput of operationInputs) { const { operationName, operationParams = {} } = operationInput;