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

fix(awslambda): remove the unsuitable undefined type (getsentry#3364) #4362

Closed
wants to merge 1 commit into from
Closed

Conversation

xr0master
Copy link
Contributor

fix for the type issue #3364

  • [v] Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@github-actions
Copy link
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@xr0master
Copy link
Contributor Author

@AbhiPrasad FYI, thanks.

@lobsterkatie
Copy link
Member

@xr0master - thanks for your contribution! I see that you were forced into a pretty funky hack at the end there (using the non-null assertion operator on undefined). Instead of doing that, I've simply removed the code path which would lead to an undefined return value. (TBH, it's not clear why it was there in the first place.)

Closing this in favor of #4448, which includes that change.

@xr0master
Copy link
Contributor Author

@lobsterkatie Hi.
It has to return Handler, and it's Promise. Simply returning undefined will break the types again. I am sure it will be something like Type 'undefined' is not assignable to type 'Handler'.
So, #4448, unfortunately, doesn't solve the problem.

I suggest creating a real project, something like this:

import type { APIGatewayProxyHandler } from 'aws-lambda';

export const fetch: APIGatewayProxyHandler = AWSLambda.wrapHandler(async (event) => {
  try {
    const data = await Promise.resolve({foo: 'bar'});

    return {
      statusCode: 200,
      body: JSON.stringify(data),
    };
  } catch (response) {
    return {
      statusCode: 500,
    };
  }
});

P.S. I also suggest that you update TS to the latest version and use the strict compiler options.

Have a happy debugging

@lobsterkatie
Copy link
Member

Hmmm... I'm not sure what you mean. It will never return undefined or a promise of undefined. My change makes it so that if there's an error, that error is always rethrown (matching the previous default behavior), so we never get as far as returning anything. Conversely, if we do make it to the return statement, it means it hasn't errored and we're returning what we always have, since that code path hasn't changed.

@xr0master
Copy link
Contributor Author

@lobsterkatie :/ Definitely, I shouldn't reply to comments at night, sorry. Indeed, you removed the problematic condition and now the problem is no longer there.

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

Successfully merging this pull request may close these issues.

2 participants