Solution skill
Lambda handler types in v3: import them from aws-lambda, not client-lambda
Complete solution
In AWS SDK v3, @aws-sdk/client-lambda types the Lambda management API (InvokeCommand, CreateFunctionCommand), not your handler.
Lambda handler types in v3: import them from aws-lambda, not client-lambda
TL;DR
In AWS SDK v3, @aws-sdk/client-lambda types the Lambda management API (InvokeCommand, CreateFunctionCommand), not your handler. For the handler signature itself, install the separate aws-lambda package: import { APIGatewayProxyHandler, SQSHandler } from 'aws-lambda'; export const handler: APIGatewayProxyHandler = async (event, context) => { return { statusCode: 200, body: 'Response body' }; }; It ships typed handlers for the common event sources (API Gateway v1/v2, SQS, SNS, S3, DynamoDB streams, scheduled events, etc.).
Use this when you run into the situation in the title.
When not to use this skill: unrelated tasks. It covers only the procedure above.
Compatibility
Tool: aws. The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
The split is intentional: client-* packages type the AWS API calls your code makes, aws-lambda types the events AWS sends into your code. If you are typing event as any, you are missing the package.
Context: Stack Overflow #67004778 (accepted answer, 16 votes): a developer moving to AWS SDK v3 for its TypeScript support could not find types for Lambda handler signatures (event, context). The @aws-sdk/client-lambda package only types the management client, not the handler. The verified answer: handler types live in the separate aws-lambda package: import { SQSHandler, SNSHandler, APIGatewayProxyHandler } from 'aws-lambda', e.g. export const handler: APIGatewayProxyHandler = async (event, context) => {...}. One package for calling the Lambda API, another for typing the function itself.
Evidence
Source: Stack Overflow #67004778 (accepted answer, 16 votes): a developer moving to AWS SDK v3 for its TypeScript support could not find types for Lambda handler signatures (event, context). The @aws-sdk/client-lambda package only types the management client, not the handler. The verified answer: handler types live in the separate aws-lambda package: import { SQSHandler, SNSHandler, APIGatewayProxyHandler } from 'aws-lambda', e.g. export const handler: APIGatewayProxyHandler = async (event, context) => {...}. One package for calling the Lambda API, another for typing the function itself.
Verified resolution: In AWS SDK v3, @aws-sdk/client-lambda types the Lambda management API (InvokeCommand, CreateFunctionCommand), not your handler. For the handler signature itself, install the separate aws-lambda package: import { APIGatewayProxyHandler, SQSHandler } from 'aws-lambda'; export const handler: APIGatewayProxyHandler = async (event, context) => { return { statusCode: 200, body: 'Response body' }; }; It ships typed handlers for the common event sources (API Gateway v1/v2, SQS, SNS, S3, DynamoDB streams, scheduled events, etc.). The split is intentional: client-* packages type the AWS API calls your code makes, aws-lambda types the events AWS sends into your code. If you are typing event as any, you are missing the package.
Source URL: https://stackoverflow.com/questions/67004778
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_sPwvuRSrlfWMFGHO9ofkMQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Lambda handler types in v3: import them from aws-lambda, not client-lambda <span>— Vectle</span></a>