Closed
Description
Describe the bug
I’m trying to implement this example from the Middy documentation. I copied it exactly into my project, but when I run it, TypeScript is unable to determine the types of event and context. I believe this example originated from a comment by @bilalq, maybe he knows how to get this to work?
src/functions/health/get.ts:32:21 - error TS7006: Parameter 'event' implicitly has an 'any' type.
32 .handler(async (event, context) => {
~~~~~
src/functions/health/get.ts:32:28 - error TS7006: Parameter 'context' implicitly has an 'any' type.
32 .handler(async (event, context) => {
~~~~~~~
My TS config:
{
"include": ["src/**/*.ts", "*.ts"],
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"declaration": false,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"module": "node16",
"moduleResolution": "node16",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2022",
"verbatimModuleSyntax": true
}
}
Environment:
- Node.js: 20
- Middy: 5.4.3
- TypeScript: 5.5.3