Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function: type inference bug when using FunctionProps #427

Open
sam-goodwin opened this issue Aug 20, 2022 · 0 comments
Open

Function: type inference bug when using FunctionProps #427

sam-goodwin opened this issue Aug 20, 2022 · 0 comments
Labels

Comments

@sam-goodwin
Copy link
Collaborator

When using FunctionProps in a Function, type inference will break:

  1. when not using props, event is properly inferred

image

  1. when specifying props, event drops to any

image

The root cause is our definition of FunctionProps, which carries with it the type parameters. They will infer to any because there are no arguments that provide the type, which breaks inference.

export interface FunctionProps<in P = any, O = any, OutP extends P = P>
  extends Omit<
    aws_lambda.FunctionProps,
    "code" | "handler" | "runtime" | "onSuccess" | "onFailure"
  > {
  /**
   * Method which allows runtime computation of AWS client configuration.
   * ```ts
   * new Lambda(clientConfigRetriever('LAMBDA'))
   * ```
   *
   * @param clientName optionally return a different client config based on the {@link ClientName}.
   *
   */
  clientConfigRetriever?: PrewarmProps["clientConfigRetriever"];
  /**
   * The destination for failed invocations.
   *
   * Supports use of Functionless {@link IEventBus} or {@link IFunction}.
   *
   * ```ts
   * const bus = new EventBus<>
   * ```
   *
   * @default - no destination
   */
  onSuccess?: FunctionAsyncOnSuccessDestination<OutP, O>;
  /**
   * The destination for successful invocations.
   *
   * @default - no destination
   */
  onFailure?: FunctionAsyncOnFailureDestination<OutP>;
}

Proposed solution: remove onSuccess and onFailure from the properties and remove all type parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant