question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

context.payload is any again with typescript ?

See original GitHub issue

Bug Report

Current Behavior

It seems payload is any again, like described in the issue https://github.com/probot/probot/issues/1366, with the latest release (I replied it worked, but now I’m not sure it did, as I am still migrating and have a lot of typescript errors)

// Your code here
module.exports = (app) => {
  app.on(
    'repository.edited',
    async (context) => {
      // context.payload is any
      // context is: (parameter) context: WebhookEvent<EventPayloads.WebhookPayloadRepository> & Context<any>
    };
  );

Expected behavior/code A clear and concise description of what you expected to happen (or code).

Environment

  • Probot version(s): v10.9.4
  • Node/npm version: Node 14 / Yarn 1.22.5
  • OS: Ubuntu
  • Typescript: 4.0.3

Possible Solution

I tried to change node_modules/probot/lib/types.d.ts :

-export declare type ProbotWebhooks = Webhooks<WebhookEvent, Context>;
+export declare type ProbotWebhooks = Webhooks<WebhookEvent, Omit<Context, keyof WebhookEvent>>;

And it seems to work: context is now:

(parameter) context: WebhookEvent<EventPayloads.WebhookPayloadRepository> & Pick<Context<any>, "github" | "log" | "event" | "repo" | "issue" | "pullRequest" | "isBot" | "config">

I could make a PR, but should we add a test somehow to make sure it will keep working ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
gr2mcommented, Oct 23, 2020

Ahhh sorry Christophe, now I get it! Okay in this case feel free to add both a test and a fix to Probot. If it works well we can adopt a similar test for @octokit/webhooks to avoid future regressions

0reactions
github-actions[bot]commented, Nov 1, 2020

🎉 This issue has been resolved in version 10.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 4.6
If it is, TypeScript can now narrow the types of variables depending on checks of other variables So in our example, a check...
Read more >
How to type check payload provided to action: React ...
An issue is in this line of code: export const UIContext = createContext<State | any>(initialState). Basically you are saying that type of ...
Read more >
React Context with useReducer and Typescript.
Let's see how we can manage a complex state, with the Context API and Typescript. In this tutorial we are building, a product...
Read more >
@actions/github context TypeScript Examples
prettier-ignore function getWebHookPayLoad(): Payload { const body: WebhookPayload = (context !== undefined && !local_debug) ? context.payload ...
Read more >
Set up Lambda proxy integrations in API Gateway
You can set up a Lambda proxy integration for any API method. ... query string parameters, any payload, associated context, and any defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found