context.payload is any again with typescript ?
See original GitHub issueBug 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:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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🎉 This issue has been resolved in version 10.10.1 🎉
The release is available on:
Your semantic-release bot 📦🚀