middy icon indicating copy to clipboard operation
middy copied to clipboard

LambdaFunctionURLHandler: Argument type error

Open mdesousa opened this issue 7 months ago • 1 comments

Describe the bug A handler of type LambdaFunctionURLHandler gives an argument type error

To Reproduce

import middy from '@middy/core';
import { LambdaFunctionURLHandler } from 'aws-lambda';

const functionUrlHandler: LambdaFunctionURLHandler = async () => '';

export const handler = middy().handler(functionUrlHandler); // argument type error

See below the full error

Argument of type 'LambdaFunctionURLHandler' is not assignable to parameter of type 'MiddyInputHandler<APIGatewayProxyEventV2, any, Context>'.
  Types of parameters 'callback' and 'opts' are incompatible.
    Type 'MiddyHandlerObject' is not assignable to type 'Callback<LambdaFunctionURLResult<never>>'.
      Type 'MiddyHandlerObject' provides no match for the signature '(error?: string | Error | null | undefined, result?: LambdaFunctionURLResult<never> | undefined): void'.ts(2345)

Expected behaviour It should compile without issues

Environment (please complete the following information):

  • Node.js: [22.12.0]
  • Middy: [6.1.6]
  • AWS SDK [1.0.7]

mdesousa avatar Apr 22 '25 20:04 mdesousa