-
I'm trying to outsource the It works great in plain webhooks code, but once I want to use some Probot methods I'm lost. 😵 Could you please give me some hint or push me to the right direction or suggest some sources. I would be interested in how to work with those complex types and how to create them. Thank you in advance!!! 🙏 Code exampleimport { Probot, Context } from 'probot';
import type { HandlerFunction } from '@octokit/webhooks/dist-types/types';
const webhooks = [
'pull_request.opened' as const,
'pull_request.reopened' as const,
];
const callBack: HandlerFunction<
typeof webhooks[number],
Context
> = async context => {
if (context.isBot) {
return;
}
context.payload.pull_request;
};
export = (app: Probot) => {
app.on(webhooks, callBack); // <- ts(2345)
}; Error
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Maybe have a look at what I did for the WIP app? I have the event handler functions in 3 different files and load them here: The function itself then looks like this: Would that approach work for you? |
Beta Was this translation helpful? Give feedback.
-
Just for record, there is working example: import { Probot, Context } from 'probot';
const webhooks = [
'pull_request.opened' as const,
'pull_request.reopened' as const,
];
function probotCallBack(
app: Probot,
context: Context<typeof webhooks[number]>
) {
if (context.isBot) {
return;
}
app.log(context.payload.pull_request);
}
export = (app: Probot) => {
app.on(webhooks, probotCallBack.bind(null, app));
}; Thanks @gr2m |
Beta Was this translation helpful? Give feedback.
Just for record, there is working example:
Thanks @gr2m